I Built a Framework-Agnostic Backend Boilerplate (Node, Bun, Express, Hono...)

Published: (December 18, 2025 at 07:59 AM EST)
2 min read
Source: Dev.to

Source: Dev.to

Why Choose One Framework When You Can Have Them All? 🧠

We all know the struggle. You start a project in Express, but then Fastify catches your eye with its speed. Or maybe Bun takes off and you want to try Hono or Elysia.

Usually, switching means rewriting your router, middleware, and request/response logic.

Not anymore.

I built BEnder, a TypeScript boilerplate that abstracts the underlying framework away, letting you write your business logic once and run it anywhere.

🧠 The “Brain” Architecture

Instead of a messy routes.js, BEnder uses a biological metaphor:

  • Neurons (Directories): Containers that automatically discover and mount routes.
  • Synapses (Files): Endpoints that process the logic.

It functions like file‑system routing (similar to Next.js), but strictly typed for backend APIs.

⚡ Write Once, Run on Node or Bun

Are you Team Node or Team Bun? It doesn’t matter.

BEnder detects your runtime and installed packages to boot up the optimal server:

  • Node.js: Natively supports Fastify (default) or Express 5.
  • Bun: Natively supports Hono or Elysia.

The Magic Code

Entry point (app.ts)

// 1. Initialize Infrastructure (auto-detects framework)
const { framework } = await initInfrastructure();

// 2. Initialize Neurons (Routes)
const [get, post] = [new GET(), new POST()];

// 3. Mount them universally
server.get('*', get.router).post('*', post.router);

Route handler (a “Synapse”)

export class CreateUser extends Synapse {
  protected async setRouter(): Promise {
    // works on Express, Fastify, Hono, AND Elysia!
    this.router.post('/create', async (req: IRequest, res: IResponse) => {
      // Unified Request/Response API
      this.responser(res, 200, { success: true });
    });
  }
}

🛡️ Unified Middleware

Security and utilities are also abstracted.

Configuration (app.config.ts)

export const appConfig = {
  security: {
    cors: true,
    helmet: true,
    rateLimit: true,
  },
};

BEnder automatically loads the correct middleware package for the active framework (e.g., @fastify/helmet for Fastify, hono/cors for Hono, or @elysiajs/limit for Elysia).

🚀 Try It Out

I’ve open‑sourced this to help developers spin up robust backends in seconds.

Clone it here: BEnder

Quick Start

# 1. Install dependencies
npm install

# 2. Pick your flavor (e.g., Bun + Hono)
npm install hono hono-rate-limiter

# 3. Run!
bun run app.ts
Back to Blog

Related posts

Read more »

Experimental Hono auth npm package

What I’m Building I’m creating an auth package that developers can drop into their app without writing the usual boilerplate login, register, JWT, email verifi...

Create Your First MCP App

TL;DR MCP Apps bring interactive UIs to conversational agents and other MCP clients. This tutorial shows how to create a simple yet powerful app source code he...