app.js
918 Bytes
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
var express = require('express')
var bodyParser = require('body-parser')
var app = express()
var router = require('./router/index')
//패스포트 관련 모듈들
var passport = require('passport')
var LocalStrategy = require('passport-local').Strategy;
var session = require('express-session')
var flash = require('connect-flash')
app.listen(3000, function () {
console.log('start! express server')
})
//static으로 요청했을때 바로 받아볼수있다.
app.use(express.static('public'))
app.use(express.static('views'))
//express 서버에 body Parser 쓰다고 알려야함.
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended: true}))
//view 엔진 사용
app.set('view engine', 'ejs')
app.use(session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: true
}))
app.use(passport.initialize())
app.use(passport.session())
app.use(flash())
app.use(router)