-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
67 lines (54 loc) · 2.1 KB
/
app.js
File metadata and controls
67 lines (54 loc) · 2.1 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
import express from 'express';//서버관리 열기
import logger from 'morgan';//서버 데이터 날라오는 에러 로그 출력 지원
import favicon from 'serve-favicon';//페이지 이름 옆에 이미지 지원
import bodyParser from 'body-parser';
import cookieParser from 'cookie-parser';//저장되어있는 쿠키 가져오기
import cookie from 'cookie';
import path from 'path';
import randomstring from 'randomstring';//랜덤 스트링 뽑아내기
import fs from 'fs';//파일 관리
import axios from 'axios';//아작스는 변수에다가 받아온 값을 정의하지 못함 에이씨오스는 가능 직관적
import moment from 'moment-timezone';//국가나 지역에 맞는 시간 가져오기
import cookieSession from 'cookie-session';//세션 보안 쿠키
import device from 'express-device';
var app = express();
import {Users} from './mongo';
import {Locates} from './mongo';
import {Foods} from './mongo';
// 뷰엔진 설정
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(cookieSession({
keys: ['h0t$ix'],//세션 비밀번호
cookie: {
maxAge: 1000 * 60 * 60 // 유효기간 1시간
}
}))
app.use(device.capture({parseUserAgent: true}));
let passport = require('./passport')(Users);
app.use(passport.initialize());
app.use(passport.session());
require('./func');
//catch 404 and forward to error handler
// app.use(function(req, res, next) {
// var err = new Error('Not Found');
// err.status = 404;
// next(err);
// });
// error handler
app.use(function(err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
// render the error page
res.status(err.status || 500);
res.render('error');
});
var router = require('./routes/index')(express.Router(), Users, Foods, Locates, passport);
app.use('/', router);
module.exports = app;