compile-time-first · serverless · typed end to end
Describe your API once, as plain values. Smite compiles that description into a validated server, a typed client and an OpenAPI document, then ships only the runtime.
Zod schemas drive validation, handler types and every generated artifact. The build-time registry folds out of production bundles, so what you deploy is small and fast.
import { http } from "@smitejs/http";
import { z } from "zod";
export const app = http.app("pets");
const pets = http.router().input({
params: z.object({ id: z.coerce.number() }),
});
pets.accept("GET", "/pets/:id").handler((ctx) => ({
status: 200,
body: { id: ctx.params.id, name: "Rex" },
}));
app.use(pets);Routes, inputs and handlers are plain values. Smite collects them at build time into a typed graph, and every artifact you need is generated from that one graph, so they can never drift apart.
serve(app) turns the description into a request handler. Inputs are validated with zod before your handler runs; serveNode puts it on node:http in one line.
$ smite devThe client() plugin compiles your app and emits a builder-style TypeScript client: paths, params, query and bodies typed from the same schemas.
$ smite generate clientopenapi() writes an OpenAPI 3.1 document from the IR, and swaggerUi mounts a browsable reference next to your routes.
$ smite generate openapiThe same app adapts to an AWS Lambda handler. Resources, injected clients and permissions are declared next to the code that uses them.
$ smite buildA route declares its zod inputs once. The handler receives validated, typed values; bad input is answered with a 400 before your code runs.
const app = http.app("wiki");
const routes = http.router().input({
query: z.object({ language: z.string() }).partial(),
params: z.object({ slug: z.string() }),
});
app.use(routes);1Collection runs only while the compile-time flag is true. Production bundles fold it to false, and esbuild drops the registry, the collectors and the generators. Read How it works for the full picture.
| package | what it gives you |
|---|---|
@smitejs/http | apps, routers, zod-validated endpoints, aspects, serve and serveNode |
@smitejs/client | build-time typed client generation and its tiny fetch runtime |
@smitejs/openapi | OpenAPI 3.1 generator plugin and Swagger UI router |
@smitejs/env | declared, validated environment variables |
@smitejs/domain | value objects, entities, specifications, ports and usecases |
@smitejs/fp | Option, Result, Either, Task, Matcher, flow |
@smitejs/cli | smite dev, smite build, smite generate and the plugin host |
@smitejs/core | the registrar: descriptors, edges and the compile-time flag |
See them all in the API reference.
yarn create smite-app hello-api
cd hello-api
yarn smite dev # generators + node:http server with auto-reload
curl "http://127.0.0.1:3000/hello?name=Ada"Then follow First steps.