OOrveth

Documentation

Examples

Phase 1 patterns — routing, validation, security, and config.

Application bootstrap

bootstrap.ts
import { Orveth } from "orveth";
import { cors } from "@orveth/cors";
import { requestId, securityHeaders } from "@orveth/security";

const app = new Orveth();

app.use(cors());
app.use(requestId());
app.use(securityHeaders());

app.get("/", (ctx) => ctx.ok({ ok: true }));

await app.listen({ port: 3000 });

Path and wildcard routing

routing.ts
app.get("/users/:id", (ctx) => ctx.json({ id: ctx.params.id }));

app.get("/files/*", (ctx) => ctx.json({ path: ctx.params["*"] }));

Zod validation

validation.ts
import { z } from "zod";
import { validateBody } from "@orveth/validation-zod";

const body = z.object({ name: z.string() });

app.post("/items", validateBody(body), (ctx) => {
  return ctx.created(ctx.valid.body);
});