Skip to content

conflicting req/res scoped variable names #142

Description

@WORMSS

I read that you guys are thinking of a version 2.0 for morgan on one of the other issues..

I didn't see a 2.0 branch so I wasn't sure what your plans are, but I was wondering if you would be implementing the ES6 Symbol technique as to not conflict with any other express middleware that could be trying to store _startTime and such on req/res.

So some something like

const START_TIME = Symbol("startTime");
const START_AT = Symbol("startAt");
const REMOTE_ADDRESS = Symbol("remoteAddress");
....
function recordStartTime() {
  this[START_AT] = process.hrtime()
  this[START_TIME] = new Date()
}
...
// And expose the Symbols incase other modules may want to hook into morgan
module.exports.START_TIME = START_TIME;
module.exports.START_AT = START_TIME;
module.exports.REMOTE_ADDRESS  = REMOTE_ADDRESS;
  • Colin

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions