mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Exit cleanup functions, authentication polish, db polish
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
const logger = require('../utils/logger.js')
|
||||
|
||||
// TODO: use this middleware in all modules
|
||||
|
||||
module.exports = function (options) {
|
||||
const loggableKeywords = options ? options.loggableKeywords : undefined
|
||||
const loggableModules = options ? options.loggableModules : undefined
|
||||
|
||||
return function (req, res, next) {
|
||||
res.on('finish', function () {
|
||||
@@ -13,15 +12,15 @@ module.exports = function (options) {
|
||||
|
||||
const ip = req.headers['cf-connecting-ip'] || req.connection.remoteAddress
|
||||
const hostname = req.hostname.replace('www.', '').split('.')[0]
|
||||
// TODO: merge req.url and req.hostname checking
|
||||
// TODO: regexp includes checking
|
||||
let toLog = loggableKeywords && loggableKeywords.some((x) => {
|
||||
|
||||
// fixme: regexp includes checking
|
||||
const hasLoggableKeyword = loggableKeywords && loggableKeywords.some((x) => {
|
||||
return req.url.includes(x)
|
||||
})
|
||||
|
||||
if (hostname.includes('dataeditor')) {
|
||||
toLog = true
|
||||
}
|
||||
const hasLoggableModule = loggableModules && loggableModules.some((x) => {
|
||||
return hostname.includes(x)
|
||||
})
|
||||
const toLog = hasLoggableModule || hasLoggableKeyword
|
||||
|
||||
logger.LogReq(req, true, res.statusCode)
|
||||
if (toLog) { logger.LogReq(req) }
|
||||
|
Reference in New Issue
Block a user