-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
48 lines (42 loc) · 1.36 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
import express from 'express';
import 'express-async-errors';
import cors from 'cors';
import morgan from 'morgan';
import helmet from 'helmet';
import authRouter from './router/auth.js';
import findMatchRouter from './router/findMatch.js';
import beforeMatchRouter from './router/beforeMatch.js';
import matchRouter from './router/match.js';
import chattingRoomRouter from './router/chattingRoom.js';
import chatRouter from './router/chat.js';
import promiseRouter from './router/promise.js';
import userDataRouter from './router/userData.js';
import { config } from './config.js';
import { sequelize } from './services/database.js';
import { Server } from 'socket.io';
import { initSocket } from './services/socket.js';
const app = express();
app.use(express.json());
app.use(helmet());
app.use(cors());
app.use(morgan('tiny'));
app.use('/auth', authRouter);
app.use('/findmatch', findMatchRouter);
app.use('/match', matchRouter);
app.use('/beforematch', beforeMatchRouter);
app.use('/chattingroom', chattingRoomRouter);
app.use('/chat', chatRouter);
app.use('/promise', promiseRouter);
app.use('/userdata', userDataRouter);
app.use((req, res, next) => {
res.sendStatus(404);
});
app.use((error, req, res, next) => {
console.error(error);
res.sendStatus(500);
});
sequelize.sync().then((client) => {
console.log('hi');
});
const server = app.listen(8080);
initSocket(server);