mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Authetication, logger middleware, db create tool
This commit is contained in:
parent
5f0b17a0db
commit
ebd27f93c1
11 changed files with 164 additions and 94 deletions
26
server.js
26
server.js
|
@ -34,9 +34,6 @@ const cors = require('cors')
|
|||
const extraModulesFile = './extraModules.json'
|
||||
const modulesFile = './modules.json'
|
||||
|
||||
const loggableKeywords = [
|
||||
'user.js'
|
||||
]
|
||||
let modules = JSON.parse(utils.ReadFile(modulesFile))
|
||||
|
||||
logger.Load()
|
||||
|
@ -57,29 +54,6 @@ try {
|
|||
const app = express()
|
||||
app.use(cors())
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
res.on('finish', function () {
|
||||
if (req.url.includes('_next/static')) {
|
||||
return
|
||||
}
|
||||
let ip = req.headers['cf-connecting-ip'] || req.connection.remoteAddress
|
||||
logger.LogReq(req, true, res.statusCode)
|
||||
|
||||
let toLog = loggableKeywords.some((x) => {
|
||||
return req.url.includes(x)
|
||||
})
|
||||
const hostname = req.hostname.replace('www.', '').split('.')[0]
|
||||
|
||||
if (hostname.includes('dataeditor')) {
|
||||
toLog = true
|
||||
}
|
||||
|
||||
if (toLog) { logger.LogReq(req) }
|
||||
if (res.statusCode !== 404) { logger.LogStat(req.url, ip) }
|
||||
})
|
||||
next()
|
||||
})
|
||||
|
||||
Object.keys(modules).forEach(function (k, i) {
|
||||
let x = modules[k]
|
||||
try {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue