최현영

app.js

Showing 1 changed file with 53 additions and 0 deletions
1 +var express = require('express')
2 + , http = require('http')
3 + , path = require('path');
4 +
5 +var bodyParser = require('body-parser')
6 + , cookieParser = require('cookie-parser')
7 + , static = require('serve-static')
8 + , errorHandler = require('errorhandler');
9 +
10 +
11 +var expressSession = require('express-session');
12 +
13 +var app = express();
14 +
15 +app.set('port', process.env.PORT || 3000);
16 +
17 +// body-parser를 이용해 application/x-www-form-urlencoded 파싱
18 +app.use(bodyParser.urlencoded({ extended: false }))
19 +
20 +// body-parser를 이용해 application/json 파싱
21 +app.use(bodyParser.json())
22 +
23 +// public 폴더를 static으로 오픈
24 +app.use('/public', static(path.join(__dirname, 'public')));
25 +
26 +// cookie-parser 설정
27 +app.use(cookieParser());
28 +
29 +// 세션 설정
30 +app.use(expressSession({
31 + secret:'my key',
32 + resave:true,
33 + saveUninitialized:true
34 +}));
35 +
36 +
37 +// 라우터 객체 참조
38 +var router = express.Router();
39 +
40 +router.route('/process/map').get(function(req, res){
41 + console.log('process/map 호출됨');
42 +});
43 +
44 +
45 +app.use('/', router);
46 +
47 +// Express 서버 시작
48 +http.createServer(app).listen(app.get('port'), function(){
49 + console.log('서버가 시작되었습니다. 포트 : ' + app.get('port'));
50 +
51 +
52 + });
53 +