diff options
author | Marvin Borner | 2020-09-30 19:46:23 +0200 |
---|---|---|
committer | Marvin Borner | 2020-09-30 19:46:23 +0200 |
commit | a5e2f2db4ebaca6a21a81e00d7506772a7c0d59b (patch) | |
tree | 4c40f6b3ab27c4c03b4f061845db747016ee442a /quotes/index.js | |
parent | 4f6fe9fc1033e388c5cdf1dab6afa799547b30ef (diff) |
Quote server bootstrap
Diffstat (limited to 'quotes/index.js')
-rw-r--r-- | quotes/index.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/quotes/index.js b/quotes/index.js new file mode 100644 index 0000000..e4d56e9 --- /dev/null +++ b/quotes/index.js @@ -0,0 +1,38 @@ +require("dotenv").config(); +const express = require("express"); +const mariadb = require("mariadb"); +const app = express(); +const pool = mariadb.createPool({ + host: process.env.DB_HOST, + user: process.env.DB_USER, + password: process.env.DB_PWD, + database: process.env.DB_NAME, +}); + +let db_conn; + +pool.getConnection() + .then((conn) => { + db_conn = conn; + db_conn.release(); + }) + .catch((err) => { + console.error(err); + db_conn = null; + }); + +app.use(express.urlencoded({ extended: true })); +app.use(express.json()); + +app.use("/", express.static(__dirname + "/public")); + +app.get("/api/list", (req, res) => { + res.send("ok\n"); +}); + +app.on("close", () => { + console.log("CLOSE"); +}); + +console.log("Listening on port 5007"); +app.listen(5007); |