-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
68 lines (56 loc) · 1.64 KB
/
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
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
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
require('dotenv').config();
const cookie = require('cookie-parser');
const session = require('express-session');
// const helmet = require('helmet');
// const http = require('http');
const app = express();
// const server = http.createServer(app);
// const io = require('socket.io')(server, { cors: { origin: '*' } });
// io.on('connection', (socket) => {
// // front -> back
// socket.on('send message', (front_message) => {
// console.log(front_message);
// //back -> front
// const msg = 'state 변경 감지';
// io.emit('receive message', msg);
// });
// socket.on('disconnect', function () {
// console.log('user disconnected: ', socket.id);
// });
// });
const passportConfig = require('./passport');
// passportConfig(app);
const { PORT } = process.env;
app.set('view engine', 'ejs');
// app.use(helmet());
app.use(
cors({
origin: true,
credentials: true,
}),
);
app.use(cookie());
// app.use(
// session({
// secret: 'secret',
// }),
// );
app.use(express.static('public'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
//라우터
const homeRouter = require('./routes/home');
const tokenRouter = require('./routes/token');
const userRouter = require('./routes/userRouter');
app.use('/', homeRouter);
app.use('/user', userRouter);
app.use('/token', tokenRouter);
const workspaceRouter = require('./routes/workspace');
app.use('/', homeRouter);
app.use('/workspace', workspaceRouter);
app.listen(PORT, () => {
console.log(`포트번호 ${PORT}번 실행`);
});