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.
β¨ Key Features
Section titled ββ¨ Key Featuresβ- β‘ 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
π Table of Contents
Section titled βπ Table of Contentsβ| Page | Description |
|---|---|
| Getting Started | Installation & creating a new project |
| Bootstrap | defineBootstrap & server configuration |
| Router | Route definition, grouping, & methods |
| Controller | Creating controllers with composeController |
| Service | Business logic with composeService |
| Middleware | Middleware & priority system |
| Response | Standardized API response with Res |
| Context | Request context (ctx) in detail |
| Exception Handler | Global & per-route error handling |
π Quick Start
Section titled βπ Quick Startβbun create gaman@latestsrc/βββ index.ts # Application bootstrapβββ router.ts # All route definitionsβββ module/ βββ controllers/ β βββ AppController.ts βββ services/ β βββ AppService.ts βββ middlewares/ βββ AppMiddleware.tssrc/index.ts
Section titled βsrc/index.tsβimport { defineBootstrap } from 'gaman';import router from './router';
defineBootstrap(async (app) => { app.mount(router); app.mountServer({ http: 3431 });});src/router.ts
Section titled βsrc/router.tsβimport { composeRouter } from 'gaman/compose';import AppController from './module/controllers/AppController';
export default composeRouter((r) => { r.get('/', [AppController, 'HelloWorld']);});src/module/controllers/AppController.ts
Section titled βsrc/module/controllers/AppController.tsβ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()); }, }),);src/module/services/AppService.ts
Section titled βsrc/module/services/AppService.tsβimport { composeService } from 'gaman/compose';
export default composeService(() => ({ WelcomeMessage() { return 'β€οΈ Welcome to GamanJS'; },}));src/module/middlewares/AppMiddleware.ts
Section titled βsrc/module/middlewares/AppMiddleware.tsβimport { composeMiddleware } from 'gaman/compose';
export default composeMiddleware(async (ctx, next) => { return next();});Run the server:
bun run devServer 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" }}π License
Section titled βπ LicenseβMIT Β© Angga7Togk