doofpi is a lightweight TypeScript framework based on web standards for building end-to-end type-safe APIs - no code generation, no build steps, no separate schema files to maintain
# Core install
bun install doofpi
npm install doofpi
pnpm install doofpiOptional: Add
zodfor schema validation and type inference from schemas.bun install doofpi zod
| Zero Boilerplate | No adapters, links, or transformers minimal setup |
| End-to-End Type Safety | Change your server, your client breaks at compile time |
| Runtime Agnostic | Bun · Cloudflare Workers · Vercel · Netlify · Deno and more |
| Zod Validation | Optional input and output validation at runtime |
| Web Standards | Built on the native Request / Response API |
| Cloudflare Email | Handle Email Routing messages with onEmail |
| Thoroughly Tested | 100% code coverage across all core features |
const d = new Doofpi().onEmail(async ({ message, env, extra }) => {
await message.forward('inbox@example.com');
});
export default {
async fetch(req: Request, env: Env, ctx: ExecutionContext) {
return d.fetch(req, env, ctx);
},
async email(message: ForwardableEmailMessage, env: Env, ctx: ExecutionContext) {
return d.email(message, env, ctx);
}
};Types come from @cloudflare/workers-types (optional peer dependency).
createClient uses the global fetch by default. Pass your own fetch to change the transport, for example to call a
Doofpi instance in-process during SSR without an HTTP round trip:
import { createClient, type ClientFetch } from 'doofpi';
const localFetch: ClientFetch = (input, init) => d.fetch(new Request(input, init));
const client = createClient<AppRoute>({
url: 'http://localhost', // only used to build an absolute URL
root: '/doofpi',
fetch: localFetch
});It also works for Cloudflare service bindings and for mocking requests in tests.
Full documentation, guides, and API reference are available at liorcodev.github.io/doofpi-docs.
| Quick Start | Get up and running in minutes |
| Core Concepts | Read & Write semantics, routing, Zod validation |
| Guides | Context, middleware, error handling, and more |
| API Reference | Full API for Doofpi, EndpointBuilder, and createClient |
| Comparison | How doofpi compares to tRPC |
Inspired by tRPC.