Module loading refactor

This commit is contained in:
MrFry 2019-10-24 14:30:41 +02:00
parent b0bc051094
commit b2310213b3
2 changed files with 41 additions and 23 deletions

@ -1 +1 @@
Subproject commit de7760ea8262febe71e697c697e3c34a87eb10df Subproject commit fe74436ab119a31fdb35f7a3bbae50a572b0fb21

View file

@ -32,11 +32,46 @@ const https = require('https')
const stat = require('./utils/stat.js') const stat = require('./utils/stat.js')
stat.Load() stat.Load()
const qmining = require('./modules/qmining.js').app const loggableKeywords = [
const main = require('./modules/main.js').app 'user.js'
const sio = require('./modules/sio.js').app ]
const stuff = require('./modules/stuff.js').app let modules = {
const old = require('./modules/old.js').app qmining: {
path: './modules/qmining.js',
name: 'qmining',
urls: [ 'qmining.frylabs.net', 'localhost' ]
},
main: {
path: './modules/main.js',
name: 'main',
urls: [ 'frylabs.net', 'www.frylabs.net' ]
},
sio: {
path: './modules/sio.js',
name: 'sio',
urls: [ 'sio.frylabs.net' ]
},
stuff: {
path: './modules/stuff.js',
name: 'stuff',
urls: [ 'stuff.frylabs.net' ]
},
old: {
path: './modules/old.js',
name: 'old',
urls: [ 'qmining.tk', 'www.qmining.tk' ]
}
}
const app = express()
Object.keys(modules).forEach(function (k, i) {
let x = modules[k]
x.app = require(x.path).app
x.urls.forEach((url) => {
app.use(vhost(url, x.app))
})
})
const locLogFile = './stats/logs' const locLogFile = './stats/logs'
const allLogFile = '/nlogs/log' const allLogFile = '/nlogs/log'
@ -93,12 +128,6 @@ function setLogTimer () {
setLogTimer() setLogTimer()
const app = express()
const loggableKeywords = [
'user.js'
]
app.use(function (req, res, next) { app.use(function (req, res, next) {
res.on('finish', function () { res.on('finish', function () {
logger.LogReq(req, true, res.statusCode) logger.LogReq(req, true, res.statusCode)
@ -111,17 +140,6 @@ app.use(function (req, res, next) {
next() next()
}) })
app.use(vhost('qmining.frylabs.net', qmining))
app.use(vhost('sio.frylabs.net', sio))
app.use(vhost('stuff.frylabs.net', stuff))
app.use(vhost('frylabs.net', main))
app.use(vhost('www.frylabs.net', main))
app.use(vhost('qmining.tk', old))
app.use(vhost('www.qmining.tk', old))
app.use(vhost('localhost', qmining))
logger.Log('Node version: ' + process.version) logger.Log('Node version: ' + process.version)
logger.Log('Listening on port: ' + port) logger.Log('Listening on port: ' + port)