mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-13 16:06:21 +00:00
25 lines
544 B
JavaScript
25 lines
544 B
JavaScript
const logger = require('./../../logger')
|
|
|
|
class DebugLogging {
|
|
constructor () {
|
|
logger.log('Initiated DebugLogging middleware.')
|
|
}
|
|
|
|
#middleware (req, res, next) {
|
|
req.locals.debug = {
|
|
ip: req.ip,
|
|
method: req.method,
|
|
path: req.path,
|
|
path_parameters: req.path_parameters
|
|
}
|
|
logger.log(`Incoming from ${req.locals.debug.ip} -> ${req.locals.debug.method} ${req.locals.debug.path}`)
|
|
return next()
|
|
}
|
|
|
|
get middleware () {
|
|
return this.#middleware.bind(this)
|
|
}
|
|
}
|
|
|
|
module.exports = DebugLogging
|