-
-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to mime-types from mime #192
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a breaking change can this target the 1.x branch along with the other breaking changes for 1.x?
Also, we need to at least document some method for users to change the mime types for files based on extension... that would be a very large and strange API gap to introduce, as setting that type of thing is common among all static file servers.
Please include the updates to the history file as part of the PR itself :)
Sure thing ✔️
Sounds good! I'm guessing that we should introduce an API specifically for this? I'll post a suggestion on it soon ✔️
Will do ✔️ |
We may need to, yes. Currently mime-types itself doesn't have one, but we probably need to do something as it is quite the feature gap. The mime module was archived for a while but has been since unarchived. The motivation behind this change is partly due to that and to simplify the dep tree. I think we may also decide there is too much work to do still to throw it into express 5 as well, as I think we all agree a top goal is to prevent further slipping of the release, lol. Sorry I don't have a direct opinion right now; just quickly typing at work and will give more thought, especially if you have more to post before I'm out tonight. |
100%, I don't want this to hold up the release at all 👍
No worries! Looking at the current API, I'm not a fan of extending global variables. Especially since any library can import One idea for an API would be something like this:
On top of this we would probably also need an The usage would look something like this: Send const send = require('send')
const mimeDB = require('mime-db')
const mimeTypes = { ...mimeDB, 'application/linusu': { ext: ['.foo'] } }
// ...
send(req, 'linusu.foo', { mimeTypes }) serve-static const serveStatic = require('serve-static')
const mimeDB = require('mime-db')
const mimeTypes = { ...mimeDB, 'application/linusu': { ext: ['.foo'] } }
const serve = serveStatic('public/linusu', { mimeTypes })
// ...
serve(req, res, (err) => console.error(err.stack)) express const express = require('express')
const mimeDB = require('mime-db')
const app = express()
const mimeTypes = { ...mimeDB, 'application/linusu': { ext: ['.foo'] } }
app.set('mime types', mimeTypes)
app.get('/', (req, res) => {
res.sendFile('linusu.foo')
})
app.use(express.static('public/linusu'))
// ... The beauty with this approach:
What do you think a good approach to move this forward is? Open an issue on expressjs/discussions to start a discussion on the API design? or submit draft PRs implementing my suggestion? or something else? |
447e1a0
to
9238dae
Compare
9238dae
to
f3c8bac
Compare
f3c8bac
to
af94f7b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this issue is old, and kind of fell off the radar. I'm going to last this as-is on the 1.0 release branch here, but you make a lot of good points in your last issue. I figure we could probably get that implemented prior to 1.0, or even after, it doesn't really matter, since it should be semver minor.
This was picked up from the Express 5.0 todo-list: expressjs/express#2237
accepts
is already usingmime-type
so currently both are being pulled in to Express:Note that
supertest
is a dev-dependency so after this change onlymime-types
should be present when adding express as a dependency.Proposal for changelog: