Skip to content

Introduction

A Lean Framework for Heavy-Duty Enterprise Performance.

GamanJS is a lightweight, fast HTTP framework built on top of Bun runtime. Designed for building structured REST APIs with a clean Controller-Service-Middleware architecture that’s easy to maintain.

  • ⚑ Blazing Fast β€” Built on Bun’s native Bun.serve() for maximum performance
  • πŸ—οΈ Structured Architecture β€” Built-in Controller / Service / Middleware pattern
  • πŸ“¦ Standardized Response β€” Consistent API response format via global Res
  • πŸ”€ Declarative Router β€” Clean route definition with composeRouter
  • 🧩 Simple Dependency Injection β€” DI via default parameters in controllers
  • πŸ›‘οΈ Exception Handling β€” Global & per-route exception handlers
  • 🎯 Middleware Priority β€” Control middleware execution order
PageDescription
Getting StartedInstallation & creating a new project
BootstrapdefineBootstrap & server configuration
RouterRoute definition, grouping, & methods
ControllerCreating controllers with composeController
ServiceBusiness logic with composeService
MiddlewareMiddleware & priority system
ResponseStandardized API response with Res
ContextRequest context (ctx) in detail
Exception HandlerGlobal & per-route error handling
Terminal window
bun create gaman@latest
src/
β”œβ”€β”€ index.ts # Application bootstrap
β”œβ”€β”€ router.ts # All route definitions
└── module/
β”œβ”€β”€ controllers/
β”‚ └── AppController.ts
β”œβ”€β”€ services/
β”‚ └── AppService.ts
└── middlewares/
└── AppMiddleware.ts
import { defineBootstrap } from 'gaman';
import router from './router';
defineBootstrap(async (app) => {
app.mount(router);
app.mountServer({ http: 3431 });
});
import { composeRouter } from 'gaman/compose';
import AppController from './module/controllers/AppController';
export default composeRouter((r) => {
r.get('/', [AppController, 'HelloWorld']);
});
import { composeController } from 'gaman/compose';
import AppService from '../services/AppService';
import type { RT } from 'gaman/types';
export default composeController(
(appService: RT<typeof AppService> = AppService()) => ({
HelloWorld(ctx) {
return Res.message(appService.WelcomeMessage());
},
}),
);
import { composeService } from 'gaman/compose';
export default composeService(() => ({
WelcomeMessage() {
return '❀️ Welcome to GamanJS';
},
}));
import { composeMiddleware } from 'gaman/compose';
export default composeMiddleware(async (ctx, next) => {
return next();
});

Run the server:

Terminal window
bun run dev

Server will start at http://localhost:3431. Access the / endpoint and you’ll get a standardized response:

{
"success": true,
"message": "❀️ Welcome to GamanJS",
"metadata": {
"requestId": "abc123...",
"timestamp": "2026-03-23T07:00:00.000Z"
}
}

MIT Β© Angga7Togk