Schelo
Runtime type safety for your APIs
Install
Add the package, then Zod if it is not already in your project (peer dependency).
How it works
You describe which URLs matter and what JSON should look like; the interceptor does the rest at runtime.
Register routes
List endpoints in routes with optional request and response Zod schemas.
Traffic is watched
Your app uses fetch; matching calls are checked automatically.
Match & validate
When the URL matches a pattern like GET /api/users/:id, JSON is validated against your schema.
Clear feedback
Failures: boxed console output with route and fields. Success: nothing printed.
Create the config
createInterceptor + a routes map (METHOD /path keys, optional Zod request / response). Failures go to the console only—no log buffer. Details: Config & API. Enable via Next.js or React.
import { createInterceptor } from "schelo";
import { z } from "zod";
export const interceptor = createInterceptor({
mode: "warn",
routes: {
"GET /api/health": {
response: z.object({ status: z.literal("ok") }),
},
"POST /api/items": {
request: z.object({ title: z.string() }),
response: z.object({ id: z.string(), title: z.string() }),
},
},
});import { createInterceptor } from "schelo";
import { z } from "zod";
export const interceptor = createInterceptor({
mode: "warn",
routes: {
"GET /api/health": {
response: z.object({ status: z.literal("ok") }),
},
"POST /api/items": {
request: z.object({ title: z.string() }),
response: z.object({ id: z.string(), title: z.string() }),
},
},
});Documentation
Setup guides, config options, and API reference in plain language.