effect-http-server

Build HTTP servers with Effect's HttpRouter, middleware, and platform layers.

3|Updated Apr 1, 2026
One-click install
npx skills add https://github.com/mpsuesser/opencode-effect-enforcer --skill effect-http-server-mpsuesser
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect-http-server
Source: https://github.com/mpsuesser/opencode-effect-enforcer/tree/main/skills/effect-http-server
Command: npx skills add https://github.com/mpsuesser/opencode-effect-enforcer --skill effect-http-server-mpsuesser

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires effect, @effect/platform-node, @effect/platform-bun.

What problem does it solve? Building HTTP servers in Effect v4 requires navigating unstable APIs like HttpRouter, HttpServerRequest, and HttpServerResponse, where route registration, schema decoding, middleware composition, and error mapping differ significantly from v3 and from conventional frameworks. ## Core Features & Use Cases - Route Registration and Serving: Register routes as Layers with HttpRouter.add, addAll, and use, then serve them via NodeHttpServer or BunHttpServer layers with graceful shutdown. - Schema-Validated Request Handling: Decode JSON bodies, forms, multipart uploads, headers, cookies, and path/search params with Schema, including file upload limits via Multipart references. - Middleware and Error Mapping: Compose router middleware that provides services or handles typed errors, and map domain errors to responses with the HttpServerRespondable protocol. - Use Case: You need a typed REST endpoint that accepts a multipart file upload, validates fields with Schema, enforces a 10 MB file limit, and returns a 413 on violation — this Skill provides the exact v4 wiring. ## Quick Start Use the effect-http-server skill to create an Effect v4 HTTP server with a schema-validated POST route and run it on NodeHttpServer.

Frequently Asked Questions about effect-http-server

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create an HTTP server with Effect v4?

Register routes as Layers with HttpRouter.add or HttpRouter.addAll, then pass them to HttpRouter.serve and provide a platform layer like NodeHttpServer.layer(createServer, { port: 3000 }). Launch the resulting layer with Layer.launch and NodeRuntime.runMain.

How do I validate request bodies with Schema in Effect HTTP routes?

Use HttpServerRequest.schemaBodyJson for JSON bodies, schemaBodyForm for multipart or url-encoded forms, and HttpRouter.schemaParams for path and search params. These return Effects that fail with SchemaError, which the server maps to a 400 response automatically.

Does Effect HttpRouter support middleware like Express?

Yes, via HttpRouter.middleware, which wraps route handlers and can provide services or handle typed errors. Pass { global: true } to apply middleware to all routes, and use built-ins like HttpMiddleware.cors, logger, and tracer.

How do I handle multipart file uploads in Effect HTTP server?

Read request.multipart to persist file parts to temp files, or use HttpServerRequest.schemaBodyMultipart with Multipart.FilesSchema for validated uploads. Enforce limits with Multipart.MaxFileSize and related Context references, catching MultipartError to return 413.

What is the difference between HttpRouter.serve and HttpServer.serve in Effect?

HttpRouter.serve builds the router from route Layers, adds logging and tracing, and runs it on the provided platform server. HttpServer.serve is lower-level, accepting any Effect that produces an HttpServerResponse without router features.

Why does my Effect HTTP route return 500 instead of my custom error?

Unhandled failures are converted at the server boundary: SchemaError becomes 400, RouteNotFound becomes 404, and anything else becomes 500. Implement HttpServerRespondable on your error class or catch it with Effect.catchTag to control the response.