A fast, lightweight REST API built with Bun, featuring a custom routing system, SQLite integration, file uploads, and a built-in logging system.
- Fast Runtime: Powered by Bun for maximum performance.
- SQLite Database: Integrated SQLite support with a clean SQL tagging system.
- Custom Logger: Built-in middleware that logs requests to the console and
app.log. - File Uploads: Native file upload handling with automated local storage.
- Consistent Responses: Unified
ApiResponseutility for structured JSON responses. - Log Viewer: Dedicated endpoint to retrieve and parse system logs.
To install dependencies:
bun installTo run the server in development mode (with hot reloading):
bun run devTo start the server:
bun startThe server will be running at http://localhost:3000.
GET /api/version: Returns the current API version.GET /api/logs: Returns parsed logs fromapp.log.
GET /api/v2/users: Get all users.POST /api/v2/create-user: Create a new user.- Body:
{ "name": "string", "email": "string" }
- Body:
DELETE /api/v2/delete-user/:id: Delete a user by ID.
POST /api/v2/upload: Upload a file (Multipart Form Data).- Field:
file
- Field:
GET /api/v2/uploads/:filename: Serve an uploaded file.GET /api/v2/test: A test page for file uploads.
src/
├── controllers/ # Request handlers
├── database/ # SQLite connection and schema
├── middlewares/ # Custom middlewares (logger, methods)
├── models/ # TypeScript interfaces
├── routes/ # Route definitions
├── utils/ # Helpers (Response, parseLog)
└── index.ts # Entry point
The API uses a custom logging middleware that records:
- Timestamp
- HTTP Method
- URL
- Status Code
- Duration (ms)
- Error Messages (if any)
Logs are saved to app.log in the root directory and can be accessed via the /api/logs endpoint.
Created with ❤️ using Bun v1.3.12