How jmunoz1992/mp3-frame-counter works
This repository provides a streaming Express API for counting supported MPEG-1 Layer III frames in uploaded MP3 files. The main flow validates a multipart upload, feeds file chunks into the counter, skips a leading ID3v2 tag, parses and counts frames (excluding a first-frame Xing index), then returns JSON. Configuration, HTTP error mapping, health checks, and 404 handling are also shown. Relationships follow the excerpts and README; no unsampled runtime wiring is inferred.
Main entry points: app.ts Express app · fileUpload.ts File upload · FrameCounter.ts Streaming counter · server.ts HTTP server
Components 13
HTTP API
- HTTP server
src/server.ts - Express app
src/app.ts - Runtime config
src/config.ts - File upload
src/routes/fileUpload.ts - Health check
src/app.ts
MP3 Counting
- Streaming counter
src/mp3/FrameCounter.ts - ID3v2 reader
src/mp3/id3.ts - Frame header parser
src/mp3/frameHeader.ts - MPEG tables
src/mp3/constants.ts - Parse types
src/mp3/types.ts
Error Handling
- HTTP error
src/errors/HttpError.ts - Error middleware
src/middleware/errorHandler.ts
Other components
- API client
Connections 16
- API client → HTTP server: sends requests
README.md - HTTP server → Express app: creates app
src/server.ts - HTTP server → Runtime config: reads port
src/server.ts - Express app → File upload: mounts router
src/app.ts - Express app → Error middleware: registers handler
src/app.ts - Express app → HTTP error: creates 404 error
src/app.ts - API client → Health check: checks health
README.md - File upload → Runtime config: reads upload settings
src/routes/fileUpload.ts - File upload → Streaming counter: feeds file chunks
src/routes/fileUpload.ts - File upload → HTTP error: creates upload errors
src/routes/fileUpload.ts - Streaming counter → ID3v2 reader: checks tag
src/mp3/FrameCounter.ts - Streaming counter → Frame header parser: parses frames
src/mp3/FrameCounter.ts - Frame header parser → MPEG tables: uses tables
src/mp3/frameHeader.ts - Streaming counter → Parse types: throws parse error
src/mp3/FrameCounter.ts - Error middleware → HTTP error: maps status
src/middleware/errorHandler.ts - Error middleware → Parse types: maps parse error
src/middleware/errorHandler.ts