-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
47 lines (36 loc) · 1.06 KB
/
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
39
40
41
42
43
44
45
46
47
const express = require("express");
const cookieSession = require("cookie-session");
const cookieParser = require("cookie-parser");
const dotenv=require("dotenv");
dotenv.config(".env");
const app = express();
// parse requests of content-type - application/json
app.use(express.json());
// parse requests of content-type - application/x-www-form-urlencoded
app.use(express.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(
cookieSession({
name: "verification",
secret: "COOKIE_SECRET", // should use as secret environment variable
httpOnly: true,
sameSite: 'strict'
})
);
// database
const db = require("./app/models");
db.sequelize.sync({force:false}).then(()=>{
console.log("Re-sync Done")
})
// simple route
app.get("/", (req, res) => {
res.json({ message: "Welcome to TODO." });
});
// routes
require("./app/routes/auth.routes")(app);
require("./app/routes/note.routes")(app);
// set port, listen for requests
const PORT = process.env.PORT || 4000;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}.`);
});