This is a simple NodeJS application that utilises ExpressJS to create an API endpoint for uploading MP3 files.The MP3 files are then stored locally using Multer before being analysed!
File analysis is performed in an asynchronous streaming method, that doesn't require the entire file loaded into memory. Making this API ideal for handling large files (hundreds of MB or more).
We process chunks from fs.createReadStream and maintain a rolling buffer to detect and count MP3 frames. The API then returns the count of MP3 frames!
- Processes chunk-by-chunk (Handles large files safely)
- No full file load in memory (Ultra low RAM footprint)
- Works for CBR & VBR
To run the app locally:
npm run devThe app can be then tested using Postman:
- Send POST request to http://localhost:3000/file-upload
- Set the request body to
form-datawith a key of 'mp3' and a value of your chosen file.
Unit tests are written using Jest and Supertest. To run the unit tests:
npm run testTo lint the project:
npm run lint
npm run lint-fixTo generate/update swagger documentation for endpoints:
npm run swagger