forked from real-project1110/BackEnd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
73 lines (70 loc) · 2.13 KB
/
Copy pathapp.js
File metadata and controls
73 lines (70 loc) · 2.13 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
const express = require('express');
const app = express();
const port = 4000;
const expressSanitizer = require('express-sanitizer');
const cookieParser = require('cookie-parser');
const morgan = require('morgan');
// //*fs and https 모듈 가져오기
// const https = require('https');
// const fs = require('fs');
// //* ccertificate와 private key 가져오기
// const options = {
// // ca: fs.readFileSync('./ca.key'),
// key: fs.readFileSync('./cert.key'),
// cert: fs.readFileSync('./cert.crt'),
// };
const cors = require('cors');
const {
errorLogger,
errorHandler,
} = require('./middlewares/error-handler.middleware');
const routes = require('./routes');
const session = require('cookie-session');
const passport = require('passport');
const passportConfig = require('./passport');
passportConfig();
const morganMiddleware = require('./middlewares/morganMiddleware');
app.use(
session({
resave: false,
saveUninitialized: false,
secret: [process.env.KAKAO_SECRET,process.env.GOOGLE_SECRET],
cookie: {
httpOnly: true,
secure: false,
},
})
);
app.use(passport.initialize());
app.use(passport.session());
app.use(cors());
//*morgan 따로 사용시 주석 풀기 (tiny,common,combined,dev) 네종류 // morgan/winston 미들웨어 사용시 주석
// app.use(morgan('dev'));
//*morgan 따로 사용시 밑에 주석 // morgan/winston 미들웨어 사용시 주석풀기
app.use(morganMiddleware);
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(expressSanitizer());
app.use(cookieParser());
app.use('/', routes);
app.use(errorLogger);
app.use(errorHandler);
// https
// .createServer(
// {
// key: fs.readFileSync(__dirname + '/key.pem', 'utf-8'),
// cert: fs.readFileSync(__dirname + '/cert.pem', 'utf-8'),
// },
// function (req, res) {
// res.write('Congrats! You made https server now :)');
// res.end();
// },
// )
// .listen(4000);
app.listen(port, () => {
console.log('Hi server open :', port);
});
// //*https 오픈
// https.createServer(options, app).listen(port, () => {
// console.log(`HTTPS server started on port 4000`);
// });