aboutsummaryrefslogtreecommitdiff
path: root/quotes/index.js
blob: e4d56e984d9ad989d6fc6ea9ef7de1558236fa94 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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);