-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
51 lines (46 loc) · 1.24 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
48
49
50
51
const express = require("express");
const path = require("path");
const cors = require("cors");
const { sequelize } = require("./models");
const { Login, Signup, Write, Follows } = require("./server/routes");
const cookieParser = require("cookie-parser");
const session = require("express-session");
const passport = require("passport");
const passportConfig = require("./passport");
const config = require("./config/config.json");
const app = express();
require("dotenv").config();
app.use(cookieParser());
app.use(express.json());
app.use(
session({
resave: false,
saveUninitialized: false,
secret: config.session.secret,
cookie: {
httpOnly: true,
secure: false,
},
})
);
app.use(passport.initialize());
app.use(passport.session());
passportConfig();
sequelize
.sync({ force: false })
.then(() => {
console.log("db연결");
})
.catch((err) => {
console.log(err);
});
app.use("/login", Login);
app.use("/signup", Signup);
app.use("/write", Write);
app.use("/follow", Follows);
app.use(express.static(path.join(__dirname, "../client/build")));
app.get("/", async function (req, res) {
sess = req.session;
res.send(express.static(path.join(__dirname, "../client/build/index.html")));
});
module.exports = app;