morgan
morgan copied to clipboard
Adding a token named token causes all subsequent tokens to break.
This works just fine:
var logger = require('morgan');
logger.token('ip', function (req, res) { return req.ip ? req.ip : "" });
logger.token('uuid', function (req, res) { return (req.token ? req.token.uuid : "") });
logger.token('token', function (req, res) { return (req.token ? req.token.token : "") });
This gives "TypeError: tokens.uuid is not a function" when called in the logger:
var logger = require('morgan');
logger.token('ip', function (req, res) { return req.ip ? req.ip : "" });
logger.token('token', function (req, res) { return (req.token ? req.token.token : "") });
logger.token('uuid', function (req, res) { return (req.token ? req.token.uuid : "") });
Ah yes, that is def a footgun. We should make it an error when trying to use a reserved word in 1.x line and also get a beta of 2.0 published which allows any token name and the other 2.0 stuff, haha.
Figured as much. Is there a list of reserved words anywhere?
Not currently, so that is another thing to add: docs for this :)