mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Logging in main, old code removal
This commit is contained in:
parent
7a40666a8f
commit
0bf83b721b
3 changed files with 63 additions and 96 deletions
53
main.js
53
main.js
|
@ -18,61 +18,19 @@
|
|||
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
const startHTTPS = true
|
||||
const siteUrl = 'https://qmining.tk' // http(s)//asd.basd
|
||||
const ircURL = 'https://kiwiirc.com/nextclient/irc.sub.fm/#qmining'
|
||||
|
||||
const express = require('express')
|
||||
const bodyParser = require('body-parser')
|
||||
const busboy = require('connect-busboy')
|
||||
const fs = require('fs')
|
||||
const app = express()
|
||||
// const http = require('http')
|
||||
// const https = require('https')
|
||||
|
||||
const logger = require('./logger.js')
|
||||
const utils = require('./utils.js')
|
||||
const actions = require('./actions.js')
|
||||
const stat = require('./stat.js')
|
||||
// const utils = require('./utils.js')
|
||||
// const actions = require('./actions.js')
|
||||
|
||||
const listedFiles = './public/files'
|
||||
const recivedFiles = 'public/recivedfiles'
|
||||
const uloadFiles = 'public/f'
|
||||
const staticFile = 'public/data/static'
|
||||
const dataFile = 'public/data.json'
|
||||
const msgFile = 'stats/msgs'
|
||||
|
||||
// https://certbot.eff.org/
|
||||
const privkeyFile = '/etc/letsencrypt/live/qmining.tk/privkey.pem'
|
||||
const fullchainFile = '/etc/letsencrypt/live/qmining.tk/fullchain.pem'
|
||||
const chainFile = '/etc/letsencrypt/live/qmining.tk/chain.pem'
|
||||
|
||||
var certsLoaded = false
|
||||
if (startHTTPS && utils.FileExists(privkeyFile) && utils.FileExists(fullchainFile) && utils.FileExists(
|
||||
chainFile)) {
|
||||
try {
|
||||
const key = fs.readFileSync(privkeyFile, 'utf8')
|
||||
const cert = fs.readFileSync(fullchainFile, 'utf8')
|
||||
const ca = fs.readFileSync(chainFile, 'utf8')
|
||||
var certs = {
|
||||
key: key,
|
||||
cert: cert,
|
||||
ca: ca
|
||||
}
|
||||
certsLoaded = true
|
||||
} catch (e) {
|
||||
logger.Log('Error loading cert files!', logger.GetColor('redbg'))
|
||||
}
|
||||
}
|
||||
|
||||
app.set('view engine', 'ejs')
|
||||
app.use(function (req, res, next) {
|
||||
res.on('finish', function () {
|
||||
logger.LogReq(req, true, res.statusCode)
|
||||
if (res.statusCode !== 404) { stat.LogStat(req.url) }
|
||||
})
|
||||
next()
|
||||
})
|
||||
app.use(express.static('public'))
|
||||
app.use(busboy({
|
||||
limits: {
|
||||
|
@ -91,9 +49,7 @@ app.use(bodyParser.json({
|
|||
// --------------------------------------------------------------
|
||||
|
||||
app.get('/', function (req, res) {
|
||||
// req.hostname
|
||||
|
||||
//res.render()
|
||||
// res.render()
|
||||
res.end('henlo')
|
||||
})
|
||||
|
||||
|
@ -161,9 +117,6 @@ app.post('*', function (req, res) {
|
|||
// utils.AppendToFile(logger.GetDateString() + ": " + "404 POST", logFile);
|
||||
})
|
||||
|
||||
var msg = ''
|
||||
stat.Load()
|
||||
|
||||
exports.app = app
|
||||
|
||||
logger.Log('Main module started', logger.GetColor('yellow'))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue