mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Merge branch 'master' of https://gitlab.com/YourFriendlyNeighborhoodDealer/question-node-server
This commit is contained in:
commit
afe09a9e8e
2 changed files with 27 additions and 22 deletions
47
server.js
47
server.js
|
@ -18,7 +18,7 @@
|
|||
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
const startHTTPS = false;
|
||||
const startHTTPS = true;
|
||||
const siteUrl = "https://qmining.tk"; // http(s)//asd.basd
|
||||
const ircURL = "https://kiwiirc.com/nextclient/irc.sub.fm/#qmining";
|
||||
|
||||
|
@ -48,21 +48,26 @@ const logFile = "stats/logs";
|
|||
const allLogFile = "/nlogs/log";
|
||||
|
||||
// https://certbot.eff.org/
|
||||
const privkeyFile = "/etc/letsencrypt/live/questionmining.tk/privkey.pem";
|
||||
const fullchainFile = "/etc/letsencrypt/live/questionmining.tk/fullchain.pem";
|
||||
const chainFile = "/etc/letsencrypt/live/questionmining.tk/chain.pem";
|
||||
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)) {
|
||||
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;
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
||||
const port = 8080;
|
||||
|
@ -73,13 +78,6 @@ var highlights = ["public", "static", "manual", "isgetting", "postfeedback",
|
|||
];
|
||||
|
||||
app.set('view engine', 'ejs');
|
||||
//app.all('*', function(req, res, next) {
|
||||
// if(req.secure) {
|
||||
// next();
|
||||
// } else {
|
||||
// res.redirect('https://' + req.hostname + req.url);
|
||||
// }
|
||||
//});
|
||||
app.use(function(req, res, next) {
|
||||
res.on('finish', function() {
|
||||
Log(req, true, res.statusCode);
|
||||
|
@ -140,10 +138,15 @@ app.get('/legacy', function(req, res) {
|
|||
|
||||
var f = utils.ReadFile(dataFile);
|
||||
var d = actions.LoadJSON(f);
|
||||
var raw = d.toString().split("\n");
|
||||
let qcount = 0;
|
||||
for (let i = 0; i < d.length; i++)
|
||||
qcount += d.Subjects[i].length;
|
||||
let scount = d.length;
|
||||
|
||||
res.render('alldata', {
|
||||
data: d
|
||||
data: d,
|
||||
scount: scount,
|
||||
qcount: qcount
|
||||
});
|
||||
|
||||
Log(req);
|
||||
|
|
|
@ -59,6 +59,8 @@
|
|||
<center>
|
||||
<h2>
|
||||
Ennek az oldalnak a tartalma dinamikusan frissül minden beküldött kérdés után
|
||||
</br>
|
||||
<%=scount%> tárgy és <%=qcount%> kérdés
|
||||
</h2>
|
||||
</center>
|
||||
<% for (var i = 0; i < data.Subjects.length; i++) { %>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue