Backend
Elysia.js
Backend API with Elysia.js
Elysia.js Backend
TurboKit uses Elysia.js - a high-performance TypeScript web framework for Bun.
Features
- Type Safety - End-to-end type inference
- Performance - Fast execution with Bun runtime
- OpenAPI - Auto-generated API documentation
- Validation - Built-in request validation
Directory Structure
apps/api/
├── src/
│ ├── index.ts # Main entry point
│ └── routes/
│ ├── auth.ts # Authentication routes
│ ├── health.ts # Health check routes
│ └── users.ts # User CRUD routes
├── tsconfig.json
└── package.jsonDevelopment
# Start only the API
cd apps/api && bun run devThe API runs on http://localhost:4101.
Main Entry Point
// src/index.ts
import { Elysia } from "elysia";
import { openapi } from "@elysiajs/openapi";
import { cors } from "@elysiajs/cors";
const app = new Elysia()
.use(cors({ origin: "http://localhost:4100" }))
.use(
openapi({
documentation: {
info: { title: "TurboKit API", version: "1.0.0" },
},
})
)
.get("/", () => ({ message: "Welcome to TurboKit API" }))
.listen(4101);
export type App = typeof app;API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | / | API info |
| GET | /health | Health check |
| GET | /openapi | Swagger UI |
| POST | /auth/login | User login |
| POST | /auth/register | User registration |
| GET | /users | List users |
| GET | /users/:id | Get user by ID |
Tip: Visit localhost:4101/openapi for interactive API documentation.