Tupik is a TypeScript web framework that is secure by construction: every route declares who may call it, validates its input and classifies the sensitive data it handles, so an API does not leak data by omission, even when the code is written by an AI assistant.
Version 1.0.0 is on npm (@tupik/core, create-tupik and the other @tupik/* packages). The public API follows semver: see the changelog.
Start a new project:
npm create tupik@latest my-apiOr add Tupik to an existing one (pick the driver for your runtime: @tupik/node, @tupik/bun or @tupik/edge):
npm install @tupik/core @tupik/node
# or
pnpm add @tupik/core @tupik/nodeTupik is for teams that want the rules people forget (authorization, validation, personal data, rate limits) to fail the build or the startup instead of depending on review.
- No route without an access rule.
accessis required by the types and checked again at startup. Public routes are declared asaccess: 'public', never by omission. - Owner checks built in.
access: { owner }answers 404 to anyone who does not own the record (BOLA, the first item of the OWASP API Top 10). - Data classes. Fields marked
pii,healthorsecretare tracked by the audit and the data map, masked in traces, andsecretfields never leave the API. Undeclared response fields are cut. - Typed error catalog. Errors are declared once and raised with
ctx.fail; clients get the union of codes. - Proof in CI.
tupik audit,tupik fuzz,tupik-lintand generated access tests check what types cannot. - Ready for coding agents. An Agent Skill,
llms.txtand anAGENTS.mdin every new project teach assistants the rules.
import { createApp, createModule } from '@tupik/core';
import { z } from 'zod';
interface User {
id: string;
}
declare module '@tupik/core' {
interface TupikRegister {
principal: User;
}
}
const notes = new Map<string, { id: string; ownerId: string; title: string }>();
const notesModule = createModule('/notes')
.get('/', {
access: 'authenticated',
handler: (ctx) => [...notes.values()].filter((note) => note.ownerId === ctx.principal.id),
})
.get('/:id', {
// Only the owner gets the note; everyone else gets 404.
access: { owner: (ctx) => notes.get(ctx.params.id)?.ownerId },
schema: { params: z.object({ id: z.string().max(64) }) },
handler: (ctx) => notes.get(ctx.params.id),
});
const health = createModule().get('/health', { access: 'public', handler: () => ({ ok: true }) });
export const app = createApp({
// Resolve the signed-in user from a session or a verified token; null means anonymous.
authenticate: (ctx): User | null => (ctx.req.headers.get('authorization') === 'Bearer demo' ? { id: 'u1' } : null),
}).register(health, notesModule);app.fetch(request) is the whole interface: serve it with @tupik/node, @tupik/bun or @tupik/edge, or
mount it inside Hono with @tupik/hono. Remove the access line from a route and the file stops compiling.
| Package | Role |
|---|---|
@tupik/core |
Router, modules, access rules, data classes, error catalog (zero dependencies) |
@tupik/schema |
Standard Schema validation and precompiled validators |
@tupik/middleware |
Sessions, CSRF, tenants, rate limits, webhooks, idempotency and more |
@tupik/node, @tupik/bun, @tupik/edge, @tupik/uws |
Runtime drivers (@tupik/uws: the uWebSockets.js server, about 35% more requests per second than node:http) |
@tupik/hono |
Mount a Tupik app inside Hono, one route at a time |
@tupik/client |
Typed client inferred from the app, SSE and WebSocket |
@tupik/openapi |
OpenAPI 3.1, tupik audit, data map, contract checks |
@tupik/testing |
In-process tests, generated access tests, tupik fuzz |
@tupik/lint |
tupik-lint: BOLA, raw rows, logged request data, hard-coded secrets |
@tupik/env |
Environment and Cloudflare bindings validated at startup |
@tupik/password |
Argon2id in WebAssembly for Workers, Node and Bun |
@tupik/infra |
Redacting logger, storage, OpenTelemetry tracing |
@tupik/mcp |
MCP server from the app, with the same access rules |
create-tupik |
Project scaffold with AGENTS.md, llms.txt and the skill |
Runtimes: Node.js 22.12 or later, Bun and Cloudflare Workers are tested. Other fetch-based runtimes may work
through @tupik/edge but are not supported yet.
- Documentation: tupik.org/docs
- Examples you can run:
examples/ - For AI assistants:
skills/tupik/SKILL.md,llms.txt - Changelog, security policy, contributing guide