aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarsVomMars2020-09-30 20:37:16 +0200
committerLarsVomMars2020-09-30 20:37:16 +0200
commitad024d82b42216f38f81e2b2f40a23c79e6c9e5c (patch)
treee683987e43a0a1d271081cbeabe44357b52b445e
parent187657c3b425839c52e93bd5604f71c583ceff91 (diff)
One project one server
-rw-r--r--.env.example4
-rw-r--r--.gitignore2
-rw-r--r--quotes/.env.example4
-rw-r--r--quotes/.eslintrc.js14
-rw-r--r--quotes/.gitignore4
-rw-r--r--quotes/index.js33
-rw-r--r--quotes/package.json17
7 files changed, 8 insertions, 70 deletions
diff --git a/.env.example b/.env.example
new file mode 100644
index 0000000..dd6613d
--- /dev/null
+++ b/.env.example
@@ -0,0 +1,4 @@
+DBHost=
+DBName=
+DBUser=
+DBPassword=
diff --git a/.gitignore b/.gitignore
index b16b65a..deae9b5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
*.db
*lock*
node_*
-*.env*
+*.env
diff --git a/quotes/.env.example b/quotes/.env.example
deleted file mode 100644
index 89f11e4..0000000
--- a/quotes/.env.example
+++ /dev/null
@@ -1,4 +0,0 @@
-DB_HOST=
-DB_USER=
-DB_PWD=
-DB_NAME=
diff --git a/quotes/.eslintrc.js b/quotes/.eslintrc.js
deleted file mode 100644
index 4d11b96..0000000
--- a/quotes/.eslintrc.js
+++ /dev/null
@@ -1,14 +0,0 @@
-module.exports = {
- "env": {
- "browser": true,
- "commonjs": true,
- "es2020": true,
- "node": true
- },
- "extends": "eslint:recommended",
- "parserOptions": {
- "ecmaVersion": 11
- },
- "rules": {
- }
-};
diff --git a/quotes/.gitignore b/quotes/.gitignore
deleted file mode 100644
index d17fe72..0000000
--- a/quotes/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-.env
-*.db
-*lock*
-node_*
diff --git a/quotes/index.js b/quotes/index.js
index e4d56e9..e90dd80 100644
--- a/quotes/index.js
+++ b/quotes/index.js
@@ -1,28 +1,6 @@
-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());
+const db = require("../db");
+const app = express.Router();
app.use("/", express.static(__dirname + "/public"));
@@ -30,9 +8,4 @@ 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);
+module.exports = app;
diff --git a/quotes/package.json b/quotes/package.json
deleted file mode 100644
index 036eb45..0000000
--- a/quotes/package.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "name": "quotes",
- "version": "1.0.0",
- "description": "",
- "main": "index.js",
- "scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
- },
- "author": "",
- "license": "MIT",
- "dependencies": {
- "dotenv": "^8.2.0",
- "eslint": "^7.10.0",
- "express": "^4.17.1",
- "mariadb": "^2.4.2"
- }
-}