-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
42 lines (31 loc) · 876 Bytes
/
app.js
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
39
40
41
42
const express = require("express");
const path = require("path");
const bodyParser = require("body-parser");
const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
// static file-serving middleware
app.use(express.static('public'));
//home page
app.use("/api", require("./api/api"));
app.use((err, req, res, next) => {
console.error(err.stack);
res.status(500).send("Something broke! Route does not exist.");
});
app.use("*", function (req, res, next) {
res.sendFile(path.join(__dirname, "..", "public/index.html"));
});
const init = async () => {
try {
// await db.sync();
app.listen(3000, () => {
console.log("Server is listening on port 3000!");
});
} catch (err) {
console.error(err);
}
};
init();
module.exports = app;