-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
38 lines (27 loc) · 867 Bytes
/
server.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
require("dotenv").config();
const express = require("express");
const cors = require("cors");
const bodyParser = require('body-parser')
const db = require("./src/models");
const auth = require("./config/auth");
const app = express();
const PORT = process.env.NODE_DOCKER_PORT || 3000;
const corsOptions = {
origin: "http://localhost:3000"
};
app.set('secretKey', auth.secretKey);
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json())
app.use(cors(corsOptions));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
db.sequelize.sync();
app.get("/", (req, res) => {
res.json({ message: "Hello world." });
});
require("./src/routes/user")(app);
require("./src/routes/auth")(app);
require("./src/routes/restaurant")(app);
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}.`);
});