BEnder is a Framework-Agnostic TypeScript boilerplate featuring a brain-inspired architecture for rapid backend development. It uses a unique Neuron/Synapse pattern that enables intuitive, file-system-based routing, running seamlessly on Node.js and Bun.
npm installInstall your framework (BEnder detects them automatically):
Fastify
*(Node)*
npm install fastify @fastify/static @fastify/cors @fastify/helmet @fastify/rate-limit @fastify/cookie
*(Bun)*
bun add fastify @fastify/static @fastify/cors @fastify/helmet @fastify/rate-limit @fastify/cookieExpress
*(Node)*
npm install express @types/express cors helmet morgan cookie-parser express-rate-limit
*(Bun)*
bun add express @types/express cors helmet morgan cookie-parser express-rate-limitKoa
*(Node)*
npm install koa @koa/router koa-bodyparser @koa/cors koa-helmet koa-morgan koa-static koa-ratelimit @types/koa @types/koa-ratelimit
*(Bun)*
bun add koa @koa/router koa-bodyparser @koa/cors koa-helmet koa-morgan koa-static koa-ratelimit @types/koa @types/koa-ratelimitHono
(Note: To run Hono on Node.js, install @hono/node-server)
*(Node)*
npm install hono @hono/node-server hono-rate-limiter
*(Bun)*
bun add hono hono-rate-limiterElysia
(Note: To run Elysia on Node.js, install @elysiajs/node)
*(Node)*
npm install elysia @elysiajs/static @elysiajs/cors @elysiajs/cookie @elysiajs/html @elysiajs/node @grotto/logysia
*(Bun)*
bun add elysia @elysiajs/static @elysiajs/cors @elysiajs/cookie @elysiajs/htmlNode.js:
npm startBun:
bun run app.tsThe server will start on the port specified in your .env file (default: 3000).
BEnder organizes routes using a brain-inspired metaphor:
- Neurons 🧠 - Container classes that automatically discover and organize routes (Directories).
- Synapses ⚡ - Endpoint handlers that process HTTP requests (Files).
Files and directories prefixed with _ (underscore) are ignored by the route discovery system, allowing for co-located helpers and tests.
Routes are automatically constructed from the file system structure:
methods/GET/ ← HTTP method (Neuron)
├── api/ ← Path segment: /api
│ └── API.ts ← Synapse handles: GET /api
└── db/ ← Path segment: /db
└── DB.ts ← Synapse handles: GET /db
Result: GET /api automatically routes to methods/GET/api/API.ts.
BEnder/
├── app.ts # Entry point - detects runtime & framework
├── app.config.ts # Centralized app configuration
├── .env # Environment variables
│
├── config/ # Configuration layer
│ └── infrastructure.ts # Framework + middleware handling (Agnostic)
│
├── methods/ # HTTP method handlers (Neurons)
│ ├── base.ts # Neuron & Synapse base classes ⭐
│ ├── GET/ # GET requests
│ └── ... # POST, PUT, DELETE, etc.
│
├── apps/ # Business logic
└── public/ # Static files
A Synapse is an endpoint handler that processes requests using the unified IRequest and IResponse interfaces.
import { Synapse } from '../../base';
import { IRequest, IResponse } from '../../../config/server/types';
export class CreateUser extends Synapse {
constructor() {
super(__dirname);
}
protected async setRouter(): Promise<void> {
// Use the agnostic helper or access this.router directly
this.router.post('/create', async (req: IRequest, res: IResponse) => {
const { code, data } = await this.tryer(async () => {
// Business logic...
return { id: 1, name: req.body.name };
});
this.responser(res, code, data);
});
}
}Key Features:
- Framework Agnostic: Code works on Express, Fastify, Hono, and Elysia without changes.
- Unified Types:
IRequest<Body, Query, Params>andIResponse. - Async Error Handling:
tryer()wraps logic with auto-logging.
- Config: Edit
app.config.tsfor CORS, Security, Rate Limits, and DB settings. - Database: Supports SQL, NoSQL, Graph, etc. Implement connection logic in
config/infrastructure.ts.
BEnder automatically applies security middleware based on current framework:
- ✅ Helmet / Secure Headers
- ✅ CORS
- ✅ Rate Limiting
- ✅ Cookie Parser
- ✅ Morgan / Logger
All configured via app.config.ts.
| Runtime | Frameworks | Status |
|---|---|---|
| Both | Fastify | ✅ Verified |
| Both | Express | ✅ Verified |
| Both | Koa | ✅ Ready for Verification |
| Both | Hono | ✅ Verified |
| Bun | Elysia | ✅ Verified |
Built with ❤️ for rapid backend development