diff options
-rw-r--r-- | README.md | 9 | ||||
-rw-r--r-- | database.js | 37 | ||||
-rw-r--r-- | index.html | 2 | ||||
-rw-r--r-- | server.js | 1 |
4 files changed, 47 insertions, 2 deletions
@@ -2,4 +2,11 @@ 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. +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: + +CREATE TABLE devs ( + id INT PRIMARY KEY AUTO_INCREMENT, + name VARCHAR(30) NOT NULL, + description VARCHAR(128), + contact VARCHAR(40) +); diff --git a/database.js b/database.js new file mode 100644 index 0000000..3a2822a --- /dev/null +++ b/database.js @@ -0,0 +1,37 @@ +class Database +{ + constructor(credentials, log) + { + this.connection = mysql.createConnection(credentials); + this.log = log; + } + query(q) + { + return new Promise((resolve, reject), () => + { + this.connection.query(q, (err, res, fields) => + { + if (err) + { + this.log(err); + reject(err); + } + resolve(res); + }); + }); + } + close() + { + this.connection.end(err => + { + if (err) + { + this.log(err); + reject(err); + } + resolve(); + }); + } +} + +exports.Database = Database; @@ -8,7 +8,7 @@ </head> <body> <header> - <h1 class="shadow">LYLL-ruokailuvuoro</h1> + <h1 class="shadow">LYLL-ruoka</h1> </header> <br> @@ -3,6 +3,7 @@ const fs = require("fs"); const url = require("url"); const parse = require("./parse.js"); const scrape = require("./scrape.js"); +const mysql = require("mysql2"); async function init() |