Build APIs Without the Headache
Autogenerated docs like FastAPI. Admin dashboard like Django. Artisan-like CLI. One schema to rule everything. Type-safe everything.
Express.js, but with superpowers.
Less Code. More Safety.
See how TBK eliminates boilerplate while giving you type safety, auto-generated docs, and validated responses out of the box.
Traditional Express
Manual everything
// Traditional Express Setup
import express from 'express';
const app = express();
// Manual validation (or none at all)
app.post('/api/users', (req, res) => {
const { email, name } = req.body;
// Manual validation
if (!email || !name) {
return res.status(400).json({ error: 'Missing fields' });
}
// No type safety
// Manual input validation
// No auto-generated docs
// No response validation
res.json({ success: true });
});TypeScript Backend Toolkit
Auto-magic everywhere
// TypeScript Backend Toolkit
import MagicRouter from '@/plugins/magic/router';
import { R } from '@/plugins/magic/response.builders';
import { z } from 'zod';
const createUserSchema = z.object({
email: z.string().email(),
name: z.string().min(2),
});
const responseSchema = R.success(z.object({
id: z.string(),
email: z.string()
}));
const router = new MagicRouter('/api/users');
router.post('/', {
requestType: { body: createUserSchema },
responses: { 201: responseSchema }
}, canAccess(), async (req, res) => {
// Fully typed request & response
// OpenAPI docs auto-generated
// Response validation enabled
// Input validated by Zod
return res.created?.({
success: true,
data: { id: '123', email: req.body.email }
});
});MagicRouter: Write Schemas, Get APIs
Define Zod schemas once. Get validated routes, typed responses, and auto-generated OpenAPI documentation. No manual work required.
// 1. Define your Zod schemas
import { z } from 'zod';
export const createUserSchema = z.object({
email: z.string().email(),
name: z.string().min(2),
age: z.number().min(18).optional(),
});
export const userResponseSchema = z.object({
id: z.string(),
email: z.string(),
name: z.string(),
createdAt: z.string().datetime(),
});Auto-Generated OpenAPI
Swagger docs generated from your Zod schemas. No manual YAML writing.
Type-Safe Responses
ResponseExtended<T> gives you typed response helpers. No more res.json() chaos.
Request & Response Validation
Zod validates all requests and responses automatically. Invalid data never reaches your handler or your client.
tbk CLI: Laravel Artisan Vibes
Scaffold modules, generate docs, seed databases - all from your terminal. Productivity on steroids.
Generate a complete module in seconds
$ pnpm tbk generate:module products --path /api/v1
✨ Generating module: products
✅ Created src/modules/products/products.dto.ts
✅ Created src/modules/products/products.model.ts
✅ Created src/modules/products/products.schema.ts
✅ Created src/modules/products/products.service.ts
✅ Created src/modules/products/products.controller.ts
✅ Created src/modules/products/products.router.ts
📁 Module structure:
products/
├── products.dto.ts # Zod schemas & types
├── products.model.ts # Mongoose model
├── products.schema.ts # Request/response schemas
├── products.service.ts # Business logic
├── products.controller.ts # HTTP handlers
└── products.router.ts # MagicRouter routes
🎯 Next steps:
1. Register router in src/routes/routes.ts
2. Customize the model with your fields
3. Implement service functions
4. Run `pnpm tbk docs:openapi` to generate docsAuto-generate docs and SDK
$ pnpm tbk docs:openapi
📝 Generating OpenAPI documentation...
✅ Scanned 12 routes across 5 modules
✅ Generated public/openapi.yml
✅ Swagger UI available at http://localhost:3000/docs
$ pnpm tbk docs:sdk
🔨 Generating TypeScript SDK...
✅ Created client/sdk/
✅ Type-safe API client ready to use in your frontend!More CLI commands
pnpm tbk generate:plugin auth-providerScaffold a new plugin
pnpm tbk generate:middleware rate-limiterCreate a custom middleware
pnpm tbk generate:factory UserGenerate factory for testing
pnpm tbk seedRun database seeders
Scaffold Complete Modules
Generate all 6 files (DTOs, model, schema, service, controller, router) following best practices.
Auto-Generate Documentation
Create OpenAPI specs and TypeScript SDKs from your existing routes.
Extend With Plugins
Generate plugins, middleware, factories, and more with a single command.
Production-Ready Features
Stop configuring. Start building. Every feature you need is already here.
MagicRouter
Auto-generated OpenAPI docs from Zod schemas. Routes with superpowers.
router.post('/', {
requestType: { body: schema },
responses: { 201: responseSchema }
}, handleCreate);Session Management
Built-in session system with MongoDB/Redis. Rotation, TTLs, max sessions.
await createSession({
userId,
userAgent: req.headers['user-agent'],
ipAddress: req.ip
});File Uploads
Formidable for file handling. S3/R2/local storage. Zod validation.
const schema = z.object({
avatar: zFile({
maxSize: 5 * 1024 * 1024,
allowedTypes: MIME_GROUPS.IMAGES
})
});Zod Validation
All requests validated with Zod. Type-safe DTOs and automatic error handling.
const userSchema = z.object({
email: z.string().email(),
name: z.string().min(2)
});Email System
React Email templates. SMTP/Resend/Mailgun. Preview UI in development.
await sendEmail({
to: user.email,
template: 'welcome',
data: { name: user.name }
});Background Jobs
BullMQ for queues. Redis-backed. Job dashboard UI at /queues.
await emailQueue.add('sendWelcome', {
email,
name
}, { delay: 5000 });Database & ORM
Mongoose for MongoDB. Migrations, seeders, and factories included.
const User = mongoose.model('User', {
email: String,
name: String
});Admin Panel
Django-style auto-generated admin UI. Full CRUD at /admin.
// Auto-generated from your models // Visit http://localhost:3000/admin
Real-time (Socket.IO)
WebSocket support with Socket.IO. Testing UI at /realtime.
io.to(roomId).emit('message', {
text: 'Hello',
userId
});Security
Helmet, CORS, rate limiting, JWT auth. Production-ready out of the box.
router.get('/', {},
canAccess(),
handleGetUser
);Caching
Redis or in-memory caching. Cache middleware for routes.
router.get('/', {},
cache({ ttl: 300 }),
handleGetItems
);OpenAPI & SDK
Generate OpenAPI specs and TypeScript SDKs from your routes.
$ pnpm tbk docs:openapi $ pnpm tbk docs:sdk
How Does TBK Stack Up?
Compare features with popular Node.js frameworks. TBK gives you Express simplicity with NestJS features.
Documentation
Developer Experience
Built-in Features
Architecture
Plugin System
Modular by design. Add features without touching core code. Every plugin can hook into the app lifecycle.
How Plugins Work
Define Plugin
Implement ToolkitPlugin interface
Register in createApp()
Plugins sorted by priority
App Starts
Plugins initialize in order
Ready to Use
Plugin features available
Create Your Own Plugin
import type { ToolkitPlugin, AppContext } from '@/types';
export const myPlugin: ToolkitPlugin = {
name: 'my-plugin',
priority: 50, // Higher priority = registered first
async register(context: AppContext) {
const { app, logger } = context;
// Add middleware
app.use((req, res, next) => {
logger.info('Request received');
next();
});
// Add routes
app.get('/my-endpoint', (req, res) => {
res.json({ message: 'Hello from plugin!' });
});
// Return URLs to display on startup
return ['http://localhost:3000/my-endpoint'];
},
async onShutdown() {
// Cleanup logic (optional)
},
};Pro tip: Use pnpm tbk generate:plugin to scaffold a plugin automatically!
Built-in Plugins (9 Total)
logger
Pino logger with pretty printing, HTTP request logging, child logger factory
observability
Prometheus metrics, request IDs, health checks at /health
security
Helmet, CORS, rate limiting, XSS protection
cache
Redis/memory caching with middleware support
magic
MagicRouter, OpenAPI generation, response validation
auth
JWT extraction, session management, canAccess() middleware
admin
Django-style admin panel at /admin
realtime
Socket.IO with testing UI at /realtime
lifecycle
Graceful shutdown handling, cleanup on SIGTERM/SIGINT
