forked from All-In-Job/backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.ts
57 lines (46 loc) · 1.35 KB
/
app.ts
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
import express from 'express';
import 'dotenv/config';
import cors from 'cors';
import { Controllers } from './apis/index';
import passport from 'passport';
import kakao from './apis/auth/strategies/kakao.strategy';
import google from './apis/auth/strategies/google.strategy';
import naver from './apis/auth/strategies/naver.strategy';
import session from 'express-session';
import swaggerFile from './common/swagger/swagger-output.json';
import swaggerUi from 'swagger-ui-express';
const app = express();
app.use(cors({ origin: '*', credentials: true }));
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(
'/api-docs',
swaggerUi.serve,
swaggerUi.setup(swaggerFile, { explorer: true }),
);
app.use(passport.initialize());
app.use(
session({
secret: process.env.SESSION_SECRET_KEY!,
resave: false,
saveUninitialized: false,
}),
);
Controllers.map((contoller) => {
app.use(contoller.path, contoller.router);
});
passport.serializeUser((user: any, done) => {
done(null, user);
});
passport.deserializeUser((user: any, done) => {
done(null, user);
});
google();
naver();
kakao();
app.get('/', (_, res) => {
res.send('서버 연결 완료');
});
app.listen(process.env.PORT, () => {
console.log('🐶🐶🐶🐶🐶백엔드 오픈🐶🐶🐶🐶🐶', process.env.PORT);
});