Effect brings concepts such as explicit error handling, dependency injection, schema-based validation, and functional composition to TypeScript.
In this workshop, we'll build a small HTTP API using Effect. After a brief introduction to the core concepts, we'll dive straight into the code: endpoints, request validation, error modeling, application services, and composition through layers.
The workshop is designed for TypeScript developers who want to understand, hands-on, how Effect can help them build applications that are more robust, testable, and maintainable.
- Getting Started
- Part 1: Effect basics
- Part 2: Building an HTTP API with Effect
- Other commands
- Editor/IDE setup
- Links
Install Node.js >= 24 and the pnpm v11 package manager.
Install dependencies:
pnpm installThen run the tests and verify they are failing:
pnpm run test:api:e2eBefore starting, set up your editor/IDE to enable the Effect LSP.
An introduction to the core concepts of Effect that you will need to build the HTTP API later on.
Run any TypeScript file with Node.js:
node ./src/exercises/1-basics/01-effect.tsYou can find a reference TODO application in src/solutions/1-basics where all the concepts of this section are used. You can also find some unit tests to see how you can test Effect programs.
You will build an HTTP API that allows a user to list workshops, view their details, and register for one.
The end-to-end tests have two purposes: they verify your implementation, and they document the contract of each endpoint, for both successful and error responses.
Once you've read them, start writing code in src/exercises/2-api/router.ts!
You can find workshop fixtures in static-workshops.ts
- Start the HTTP server in watch mode:
pnpm run start:api(http://localhost:3000) - Run unit tests:
pnpm run test:api - Run end-to-end tests:
pnpm run test:api:e2e
If you are stuck or would like to see how it could be implemented, check out the solutions directory.
Type check:
pnpm run typecheck
# or watch mode
pnpm run typecheck:wTest in watch mode:
pnpm run test:w:<type-of-tests> # e.g. pnpm run test:w:api:e2eExecute any TypeScript file:
node ./src/path/to/file.tsLinter (useful advice from Effect LSP):
pnpm run lintFormat code:
pnpm run format- Install recommended extensions
- Allow the TypeScript settings to leverage the Effect LSP.
- Install OXC plugin for linter
- Settings > Languages & Frameworks > Typescript > In the "Typescript" dropdown, select the repository TypeScript in
node_modulesto leverage the Effect LSP.
- Effect V4: https://effect.website/docs/v4/onboarding
