A high-performance API Management Dashboard built with Bun, Hono, MariaDB, Drizzle ORM, and Tailwind CSS.
- Authentication: Secure Login/Logout with JWT and Cookies.
- Admin Dashboard:
- Manage Users (Activate/Deactivate, Reset Password).
- Global Statistics.
- Audit Logs for Admin actions.
- User Dashboard:
- Manage API Keys (Create, List, Revoke).
- Secure API Key generation (Keys shown once, hashed storage).
- API Security:
- API Key Middleware Validation.
- Strict Access Control: If a User is deactivated by Admin, all their API Keys are instantly rejected, even if valid.
- Access Logging.
- Runtime: Bun 1.x
- Framework: Hono
- Database: MariaDB
- ORM: Drizzle ORM
- Styling: Tailwind CSS (Server-side usage via static file) & Tabler Icons
- Bun installed
- MariaDB running
-
Clone & Install
bun install
-
Setup Environment Variables
Copy .env.example to .env and configure your credentials:
cp .env.example .envKonfigurasi GitHub OAuth (Opsional):
-
Buat OAuth App di GitHub Developer Settings.
-
Set Authorization callback URL ke
http://your-domain.com/auth/github/callback. -
Isi
GITHUB_CLIENT_IDdanGITHUB_CLIENT_SECRETdi.env. -
Database Setup Ensure MariaDB is providing a database (e.g.,
api_management). Update.envif necessary:DB_HOST="localhost" DB_USER="root" DB_PASSWORD="root" DB_NAME="api_management" DB_PORT=3306 HOST="localhost" PORT=8080
-
Migrations Push the schema to the database:
bunx drizzle-kit push
-
Seed Admin User Create the initial admin account (
banghasan@gmail.com/admin123):bun seed.ts
-
Run the App
bun --watch src/index.tsx
- Development:
bun run dev(Watches for changes) - Start:
bun run start(Production mode) - Database Push:
bun run db:push - Seed DB:
bun run seed
To use the API, include the X-API-KEY header:
curl -H "X-API-KEY: sk_your_key_here" http://localhost:8080/api/v1/resourceCheck if an API key is valid and retrieve user info.
curl -H "X-API-KEY: sk_your_key_here" http://localhost:8080/api/v1/validateResponse:
{
"valid": true,
"user_id": 1,
"username": "user123",
"role": "user",
"timestamp": "2025-01-01T12:00:00.000Z"
}