Install
@forst/cli first. Add a postinstall script that runs forst generate ..
Run generate once before you import @forst/gen.
Details are on the Installation page.effect, enable Effect mode, then regenerate:
Effect.provide, TypeScript reports an unsatisfied R channel. That is expected. Provide ForstClientLive (or a custom layer) before you run the program.
Full generate fields live on the CLI reference.
Two separate points
Promise mode keeps structural compatibility. Default clients inline a small tagged-error helper. Every invoke failure carries a readonly_tag that matches the Data.TaggedError contract, so Effect.catchTag works without adding effect as a runtime dependency.
Effect mode uses real Effect errors. With generate.effect: true, invoke, domain, and harness errors extend Data.TaggedError from the effect peer. Equal.equals and other Effect APIs work on error values. Function returns become Effect values with a typed error channel.
What changes
Both modes import the package handle (for example
$auth from @forst/gen/auth) and call $auth.VerifyPassword(...).
Errors
Catch by tag in either mode:Wiring
FORST_BASE_URL in production. The client never spawns a server when NODE_ENV is production.
Testing
Same three levels as Testing, expressed as layers. One method withLayer.mock:
UnimplementedError). That is why Effect mode requires effect >=3.17.0.
Whole client with ForstTestLayer:
Promise, or an Effect.
Wire level with a fake transport, when you need to assert payloads or simulate a specific failure. Provide a mock ForstTransport under the real package services. See Testing for the Promise mode equivalents.
Real invoke server with the test trio that mirrors ForstClientLive / ForstClientLayer / makeForstClientRuntime. Install optional @forst/cli, then:
makeForstTestServer() and call dispose() in afterAll. See Testing.
Requirements
- Install
effectin your app (>=3.17.0). - Set
"generate": { "effect": true }inftconfig.json. - Run
npx forst generate .after changing that flag.
effect version is missing or too old, generate fails and names the version it found, the floor (>=3.17.0), and why.
Related
Call Forst from Node
Promise mode calls, tagged errors, and
.safe().Testing
withForstTestScope for Promise mode.Installation
@forst/cli, postinstall, and first generate.Generate a TypeScript client
Subpaths and
@forst/gen imports.CLI reference
Full
generate configuration table.