A secure, high-performance music metadata and streaming API built with Hono, LibSQL (Turso), and ImageKit. Designed for Vercel Serverless deployment.
- High Performance: Built on Hono for minimal latency.
- Secure: Strict API Key authentication (Master Key for writes, User Keys for reads) and security hardening.
- Media Optimization: Automatic image conversion to WebP and smart storage management with ImageKit.
- Type Safe: Full TypeScript implementation with Zod validation.
- RESTful: Adheres to strict REST principles with resource-based endpoints.
- Framework: Hono
- Runtime: Node.js 20 (Vercel Serverless)
- Database: Turso (LibSQL)
- Storage: ImageKit (with Image & Audio support)
- Validation: Zod
- Documentation: Static HTML/JSON generator
The project follows a clean MVC architecture within the src directory:
src/
├── config/ # Database and Environment configuration
├── controllers/ # Request handlers and business logic
├── middlewares/ # Authentication and Security middleware
├── routes/ # Endpoint definitions
├── services/ # External services (ImageKit, Sharp)
├── scripts/ # Database management utilities
├── app.ts # Application entry point
└── server.ts # Local development server
Copy .env.example to .env and configure the following variables:
# Server
PORT=3000
# Security
MASTER_KEY=lament-your-secure-key-here
# Database (Turso)
TURSO_DATABASE_URL=libsql://...
TURSO_AUTH_TOKEN=...
# Storage (ImageKit)
IMAGEKIT_PUBLIC_KEY=...
IMAGEKIT_PRIVATE_KEY=...
IMAGEKIT_URL_ENDPOINT=https://ik.imagekit.io/...
# Optional: Specific creds for Audio/Image separation
IMAGEKIT_AUDIO_...
IMAGEKIT_IMAGE_...- Node.js >= 18
- npm
npm installStart the development server with hot-reload:
npm run devThe API will be available at http://localhost:3000.
Documentation is served at the root /.
This project includes a built-in CLI for managing the Turso database.
npm run db:do list-tablesnpm run db:do list-rows <table_name>
# Example: npm run db:do list-rows tracksnpm run db:do query "SELECT * FROM tracks LIMIT 5"Apply changes from schema.sql to the database:
npm run db:pushFull documentation is available at the root endpoint / when running the server.
/tracks: Manage music tracks/artists: Manage artist profiles/albums: Manage albums and collections/categories: Manage genres/users: Manage users/api-keys: Manage access keys
/upload: Upload media files (multipart/form-data)
The project is optimized for Vercel.
- Install Vercel CLI:
npm i -g vercel - Deploy:
vercel
- Important: Add your
.envvariables to Vercel Project Settings.
ISC