Type-safe, spec-compliant JSON:API v1.1 on Effect's HttpApi and Schema: define a resource once and derive its documents, payloads, query parameters, endpoints, errors and typed client.
Caution
Experimental and pre-1.0, largely written with Claude Code. The API may change between minor versions.
pnpm add @thomasfosterau/effect-jsonapi effecteffect (^4.1.0) is a peer dependency. Node.js 22 or newer.
import { Schema } from "effect";
import { HttpApi } from "effect/http-api";
import { Endpoint, Group, Query, Resource } from "@thomasfosterau/effect-jsonapi";
const Article = Resource.make("articles", {
attributes: { title: Schema.NonEmptyString, body: Schema.String },
});
const Api = HttpApi.make("blog").add(
Group.make(
Article,
Endpoint.get(Article, { include: true }),
Endpoint.list(Article, { page: Query.Page.Offset }),
),
);Implement the group with HttpApiBuilder and Handlers.data / Handlers.collection, and provide Middleware.layer.
| Import | What it is |
|---|---|
@thomasfosterau/effect-jsonapi |
Every module as a namespace (Resource, Endpoint, Handlers, Client, …). |
@thomasfosterau/effect-jsonapi/schema |
The wire types alone, without Effect's HTTP modules. |
@thomasfosterau/effect-jsonapi/<Module> |
One module, e.g. /Resource, /Endpoint. |
- Guides: resources, endpoints, handlers, queries, the client, the conformance kit.
- Examples and the doc comment on every export.
- Contributing, security, publishing.
MIT licensed.