-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
60 lines (50 loc) · 1.23 KB
/
index.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
import express from "express";
import cors from "cors";
import router from "./routes/index.js";
import dotenv from "dotenv";
import passport from "passport";
import "./models/index.js";
import session from "express-session";
import path from "path";
const __dirname = path.resolve();
dotenv.config();
const app = express();
const corsOption = {
origin: process.env.CORS,
Credential: true,
optionSuccessStatus: 200,
};
app.set("views", __dirname + "/views");
app.set("view engine", "ejs");
app.use(cors(corsOption));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(
session({
secret: "SECRET_CODE",
resave: true,
saveUninitialized: false,
cookie: { maxAge: 2400 * 60 * 60 },
})
);
app.use(passport.initialize());
app.use(passport.session());
app.get("/", (req, res) => {
if (req.user) {
const { profile, userId, profileImg } = req.user;
const user = {
userName: profile.nickname,
userId: userId,
profileImg: profileImg,
};
console.log("유저확인", user);
res.send({ user });
} else {
res.send({});
}
});
app.use("/api", router);
app.listen(process.env.PORT || 3000, () => {
console.log("서버 연결 성공");
});
export { app, express };