diff options
author | joel <joel.h.kronqvist@gmail.com> | 2021-12-26 14:56:41 +0200 |
---|---|---|
committer | joel <joel.h.kronqvist@gmail.com> | 2021-12-26 14:56:41 +0200 |
commit | b05479c0d40040c52dbd82d36ad6e206acfdc7c6 (patch) | |
tree | 897d41d63062dfe2b72d62f7ca55f23ddddb03da /server.js | |
parent | cd36848829db0b5228f9532a10bb15577eb7cff9 (diff) | |
download | LYLLRuoka-b05479c0d40040c52dbd82d36ad6e206acfdc7c6.tar.gz LYLLRuoka-b05479c0d40040c52dbd82d36ad6e206acfdc7c6.zip |
Implemented https
Diffstat (limited to 'server.js')
-rw-r--r-- | server.js | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -1,4 +1,5 @@ -const http = require("http"); +//const http = require("http"); +const https = require("https"); const fs = require("fs"); const url = require("url"); const parse = require("./parse.js"); @@ -17,13 +18,21 @@ async function init() const errorPath = "./404/index.html"; // await for needed things in async - let [shiftCont, classCont, foodsThisWeek, foodsNextWeek] = await Promise.all([ + let [shiftCont, classCont, foodsThisWeek, foodsNextWeek/*, httpsKey, httpsCert*/] = await Promise.all([ openFile("./shifts.txt"), openFile("./classes.txt"), scrape.food(scrape.link(1)), - scrape.food(scrape.link(2)) + scrape.food(scrape.link(2)), + //openFile("../Certificate/key.pem"), + //openFile("../Certificate/cert.pem") ]); + // https options, you need to get a certificate in the file ../Certificate for the server to work + const httpsOpts = { + key: fs.readFileSync("../Certificate/key.pem"),//httpsKey, + cert: fs.readFileSync("../Certificate/cert.pem")//httpsCert + }; + // get the food shift "database" shiftCont = shiftCont.toString("utf-8").replaceAll("\r", ""); // \r because of the \r\n newline on windows which creates problems classCont = classCont.toString("utf-8").replaceAll("\r", ""); @@ -59,7 +68,7 @@ async function init() } // start server - http.createServer(server).listen(8080); + https.createServer(httpsOpts, server).listen(8080); } |