Вопрос

I'm looking at GhostJS source code for learning Nodejs. I didn't understand why these 2 calls with different params for the same function:

https://github.com/TryGhost/Ghost/blob/688dd363cdf0084c20dd243b02c26afb6ebcabbe/core/server.js#L205-L206

Anyone could explain why that?

Thanks =D

EDIT: This is the code at time of writing:

server.use('/ghost/upload/', express.multipart());
server.use('/ghost/upload/', express.multipart({uploadDir: __dirname + '/content/images'}));

EDIT 2 See this github issue: https://github.com/TryGhost/Ghost/issues/1511

Это было полезно?

Решение

Can be traced back to the first commit for this file, where bodyParser() was used.

This adds two middlewares. The first multipart middleware will flag the body as parsed and do what it has to do:

req._body = true;

... and in the second run, the middleware won't do anything, as the body is already parsed:

return function multipart(req, res, next) {
    if (req._body) return next();
    ...
}

This looks like a mistake to me.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top