aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md9
-rw-r--r--database.js37
-rw-r--r--index.html2
-rw-r--r--server.js1
4 files changed, 47 insertions, 2 deletions
diff --git a/README.md b/README.md
index f118d5f..7c60f52 100644
--- a/README.md
+++ b/README.md
@@ -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;
diff --git a/index.html b/index.html
index c9f6c4c..90e4a9b 100644
--- a/index.html
+++ b/index.html
@@ -8,7 +8,7 @@
</head>
<body>
<header>
- <h1 class="shadow">LYLL-ruokailuvuoro</h1>
+ <h1 class="shadow">LYLL-ruoka</h1>
</header>
<br>
diff --git a/server.js b/server.js
index d26da04..4b1e8a3 100644
--- a/server.js
+++ b/server.js
@@ -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()