-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
51 lines (41 loc) · 1.21 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
/**
* Module dependencies.
*/
var express = require('express')
, passport = require('passport')
, site = require('./site')
, oauth2 = require('./oauth2')
, user = require('./user')
, util = require('util')
// Express configuration
var app = express.createServer();
app.set('view engine', 'ejs');
app.use(express.logger());
app.use(express.cookieParser());
app.use(express.bodyParser());
app.use(express.session({ secret: 'keyboard cat' }));
/*
app.use(function(req, res, next) {
console.log('-- session --');
console.dir(req.session);
//console.log(util.inspect(req.session, true, 3));
console.log('-------------');
next()
});
*/
app.use(passport.initialize());
app.use(passport.session());
app.use(app.router);
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
// Passport configuration
require('./auth');
app.get('/', site.index);
app.get('/login', site.loginForm);
app.post('/login', site.login);
app.get('/logout', site.logout);
app.get('/account', site.account);
app.get('/dialog/authorize', oauth2.authorization);
app.post('/dialog/authorize/decision', oauth2.decision);
app.post('/oauth/token', oauth2.token);
app.get('/api/userinfo', user.info);
app.listen(3000);