forked from app-and-me/2024AppnMeWebsite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
52 lines (43 loc) · 1.63 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
const express = require('express');
const path = require('path');
const mysql = require('mysql2');
const bodyParser = require('body-parser');
const app = express();
const port = 3000;
// EJS를 템플릿 엔진
app.set('view engine', 'ejs');
// 정적 파일 제공 설정
app.use(express.static(path.join(__dirname, 'public')));
// db
const db = require('./database/database');
// body-parser 설정
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
// 라우터 추가
const membersRouter = require('./routes/members'); // 부원 소개
const applicationRouter = require('./routes/application'); // 지원하기
const boardRouter = require('./routes/board'); // QnA
const recordsRouter = require('./routes/records'); // 활동 기록
const uploadRouter = require('./routes/upload'); // QnA 업로드
const studentsRouter = require('./routes/students');
const messagesRouter = require('./routes/messages');
const studentsListRouter = require('./routes/students-list');
app.use('/members', membersRouter);
app.use('/application', applicationRouter);
app.use('/board', boardRouter);
app.use('/records', recordsRouter);
app.use('/upload', uploadRouter);
app.use('/api/students', studentsRouter);
app.use('/api/messages', messagesRouter);
app.use('/api/students-list', studentsListRouter);
// 404
app.get('/404', (req, res) => {
res.status(404).render('error', {error: {code: 404, message: '요청한 페이지를 찾을 수 없어요.'}});
})
app.get('/', (req, res) => {
res.render('index');
});
// 서버 시작
app.listen(port, () => {
console.log(`http://localhost:${port}`);
});