Faftech Music API is a lightweight Node.js + Express application designed to serve and upload .mp3
audio files, complete with metadata duration extraction. It exposes two key endpoints: one for retrieving a list of available music files, and another for uploading new files.
- 🚀 Fast and simple API for
.mp3
files - 📁 Static serving of uploaded audio
- 🕒 Extracts duration from audio metadata
- 🎯 Supports cross-origin requests (CORS)
- ⬆️ Upload
.mp3
viamultipart/form-data
- Node.js
- Express.js
- Multer (for handling file uploads)
- music-metadata (to parse audio metadata)
- TypeScript (optional)
faftech-music-api/
├── public/
│ └── audio/ # Uploaded .mp3 files are saved here
├── src/
│ └── index.ts # Main Express app
├── package.json
├── tsconfig.json # TypeScript config (if applicable)
└── README.md
git clone https://github.com/fikriaf/Music-API.git
cd Music-API/faftech-music-api
npm install
npm start
Or with TypeScript (if available):
npx ts-node src/index.ts
Returns a list of all .mp3
files with metadata:
Response:
[
{
"id": 1,
"title": "Sample Track",
"file": "sample.mp3",
"url": "/audio/sample.mp3",
"duration": "2:34"
}
]
Upload .mp3
file using multipart/form-data
. Field name must be file
.
Request:
POST /api/upload
Content-Type: multipart/form-data
Form field:
file
: The.mp3
file to upload
Response:
{ "message": "Upload berhasil", "file": "track.mp3" }
CORS is enabled for all origins.
MIT