A RESTful API for managing artists and their music releases, built with Cloudflare Workers, D1 Database, and Hono.
- Artist Management
- Create and manage artists with name, bio, and genre
- Filter artists by genre
- Release Management
- Create and manage music releases (albums/singles)
- Track release status (unreleased, released, trending)
- Filter releases by artist, genre, or status
- Runtime: Cloudflare Workers
- Database: D1 (SQLite)
- Framework: Hono
- Language: TypeScript
- Node.js (v18 or later)
- NPM package manager
- Cloudflare Wrangler CLI
- Clone the repository and then access to it:
cd max-artists- Install dependencies:
npm install- Initialize the database:
npm run db:setupStart the development server:
npm run devThe API will be available at http://127.0.0.1:8787
Please import into postman the file Max-API.postman_collection in order to access the following endpoints:
POST /artists
Content-Type: application/json
{
"name": "Jane Doe",
"bio": "Indie pop sensation",
"genre": "Indie Pop"
}GET /artists?genre=Indie+Pop&name=The+SmithsPOST /releases
Content-Type: application/json
{
"title": "Breaking Free",
"release_date": "2025-04-01",
"status": "unreleased",
"genre": "Indie Pop",
"artist_id": "artist_123"
}GET /releases?artist_id=artist_123&genre=Indie+Pop&status=releasedCREATE TABLE IF NOT EXISTS artists (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
bio TEXT,
genre TEXT NOT NULL
);CREATE TABLE IF NOT EXISTS releases (
id TEXT PRIMARY KEY,
title TEXT NOT NULL,
release_date TEXT NOT NULL,
status TEXT NOT NULL,
genre TEXT NOT NULL,
artist_id TEXT NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists(id)
);src/
├── adapters/ # Framework adapters (HTTP, routes)
├── core/ # Business logic and domain
├── infrastructure/ # Database and external services
└── common/ # Shared utilities and types
npm run dev- Start development servernpm run sql- Execute SQL commandsnpm run sql-file- Execute SQL from a filenpm run db:setup- Execute SQL schema.sql file
The API uses a consistent error response format:
{
"error": {
"message": "Error description",
"status": 400
}
}