-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
61 lines (50 loc) · 1.32 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const express = require("express");
const app = express();
const cors = require("cors");
const bodyParser = require("body-parser");
const cookieParser = require("cookie-parser");
const session = require("express-session");
// importing config
const config = require("./config");
// importing routes
const noteRouter = require("./routes/notes");
const aboutRouter = require("./routes/about");
const userRouter = require("./routes/user");
const adminRouter = require("./routes/admin");
//session
// app.use(
// session({
// secret: "secret",
// saveUninitialized: true,
// resave: false,
// cookie: {
// sameSite: false,
// secure: false,
// maxAge: 1000 * 60 * 60 * 24,
// httpOnly: false,
// path: "",
// },
// })
// );
// cors
app.use(
cors({
origin: "http://localhost:8080",
methods: ["POST", "PUT", "GET", "DELETE", "OPTIONS", "HEAD"],
credentials: true,
})
);
// body parser
app.use(bodyParser.json());
// cookie parser
// app.use(cookieParser());
// routes
app.use("/", userRouter);
app.use("/notes", noteRouter);
app.use("/about", aboutRouter);
app.use("/admin", adminRouter);
// connection
const port = config.port;
app.listen(port, () => {
console.log(`Backend is running on port ${port}`);
});