-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
36 lines (30 loc) · 817 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
require("dotenv").config();
const cors = require("cors");
const morgan = require("morgan");
const express = require("express");
const session = require("express-session");
const pageRouter = require("./routes/page");
const authRouter = require("./routes/auth");
const searchRouter = require("./routes/search");
const app = express();
app.use(cors());
const env = process.env;
app.set("port", process.env.PORT || 3000);
if (env.NODE_ENV === "production") {
app.use(morgan("combined"));
} else {
app.use(morgan("dev"));
}
app.use(
session({
secret: env.SESSION_SECRET,
resave: false,
saveUninitialized: false,
})
);
app.use("/", pageRouter);
app.use("/auth", authRouter);
app.use("/search", searchRouter);
app.listen(app.get("port"), () => {
console.log(app.get("port"), "node start!");
});