diff options
| -rw-r--r-- | .gitignore | 4 | ||||
| -rw-r--r-- | README.md | 7 | ||||
| -rw-r--r-- | scrape.js | 2 | ||||
| -rw-r--r-- | server.js | 9 | 
4 files changed, 15 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1ca582b --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +Classes +node_modules +package-lock.json +shifts.txt
\ No newline at end of file @@ -2,7 +2,12 @@  Readme coming soon!  ## Setup -If you want to set up the server, you will have to get a SSL certificate or generate one yourself. If you want to run a dedicated server that can update, you also need to add the cron jobs from crontab\_add. You must create a MySQL DB and give its login info in ../dblogin.txt. The database should have the following tables set up: +You will need a SSL certificate if you want to use https. +You need to install node.js and MySQL (+ npm install mysql2). +You will need to update the server with the help of the food shift message and a tab separated list of classes (just copypaste from excel from the Kurssitarjotin) +You probably want to set up cron to run some cronjobs from crontab_add.txt. +You need to provide the login info to the MySQL DB in ../dblogin.txt. Logging in as root was found problematic on Mint, but feel free to try if you want to. +You should create the following tables, because the server code wont do it for you.  CREATE TABLE shiftnames (  	day INT, @@ -1,5 +1,5 @@  const https = require("https"); -const parse = require("./DBPARSE.js"); +const parse = require("./dbparse.js");  const fs = require("fs");  const events = require("events"); @@ -32,8 +32,8 @@ async function init()  		scrape.food(scrape.link(1)),  		scrape.food(scrape.link(2)),  		openFile("../dblogin.txt"), -    openFile("../Certificate/key.pem"), -    openFile("../Certificate/cert.pem") +		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 @@ -93,7 +93,7 @@ async function init()  	}  	// start server -	const runningServer = http.createServer(server).listen(8080); +	const runningServer = https.createServer(httpsOpts, server).listen(8080);  	// stop server  	async function closeServer() { @@ -160,7 +160,7 @@ async function buildMain(args)  	const d = new Date();  	let day = d.getDay();  	day = (day + +(day === 0) * 7) - 1; -	const actualDay = day; +	const actualDay = day + (+(day === 0) * 7);  	day = +(!(day === 5) && !(day === 6)) * day;  	if ((typeof query.day === "string") && (parseInt(query.day).toString() === query.day) && (!isNaN(parseInt(query.day))) && (parseInt(query.day) >= 0) && (parseInt(query.day) < 5))  		day = parseInt(query.day); @@ -216,7 +216,6 @@ async function buildMain(args)  	// get the food  	day += (day === 0) * 7; -	actualDay += (actualDay === 0) * 7;  	let food;  	food = foods[ +(day < actualDay) ][day];  	if (food !== undefined)  | 
