pm2 serve: add e-book MIME types
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 43.3k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Currently, the MIME table in lib/API/Serve.js doesn't cover e-book formats: epub, fb2, mobi, azw3. Since anything not in the table is served as text/plain, an .epub served by pm2 serve arrives labelled as text: the browser renders the zip bytes instead of downloading the file, and readers that dispatch on Content-Type do not recognise it.
Reproduction
mkdir -p /tmp/serve-demo && cd /tmp/serve-demo
printf 'PK\x03\x04' > book.epub
printf 'PK\x03\x04' > book.pdf
pm2 serve . 8080
curl -sI http://localhost:8080/book.epub | grep -i content-type # text/plain
curl -sI http://localhost:8080/book.pdf | grep -i content-type # application/pdf
Suggested change
Four entries in contentTypes:
'epub': 'application/epub+zip',
'fb2': 'application/x-fictionbook+xml',
'mobi': 'application/x-mobipocket-ebook',
'azw3': 'application/vnd.amazon.mobi8-ebook',
Happy to open a PR if the change looks welcome.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect the MIME table in lib/API/Serve.js, then run the issue's pm2 serve and curl reproduction commands. Done means .epub, .fb2, .mobi, and .azw3 responses return the specified e-book MIME types instead of text/plain.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 90/100