forked from chris-lin/drawlife
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
72 lines (57 loc) · 1.82 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* Module dependencies.
*/
var express = require('express');
var http = require('http');
var app = module.exports = express();
var parseCookie = require('connect').utils.parseCookie,
MemoryStore = require('connect/lib/middleware/session/memory');
//建立一个memory store的实例
var storeMemory = new MemoryStore({
reapInterval: 60000 * 10
});
// mongoose setup
//require( './db' );
//admin setup
//var admin = require('./admin');
// Configuration
app.engine('.ejs', require('ejs').__express);
app.configure(function(){
app.set('port', process.env.PORT || 8000);
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.favicon());
app.use(express.logger());
app.use(express.cookieParser());
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.session({
secret: 'OSSII Chat',
store: storeMemory
}));
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});
// Routes
var routes = require('./routes');
app.get('/', function (req, res) {
res.sendfile(__dirname + '/public/index.html');
});
//~ app.get('/', routes.index);
app.post('/login', routes.login);
app.get('/room', routes.room );
app.post('/create', routes.create );
app.get('/logout', routes.logout );
//app.get('/admin', auth.requireLogin, auth.requireAdmin, routes.admin );
//app.get('/admin/user', auth.requireLogin, auth.requireAdmin, routes.admin );
//app.get('/admin/user', routes.userManager );
//app.get('/del_user', admin.del_user );
/*
var server = http.createServer(app)
, io = require('socket.io').listen(server);
server.listen(3000,function(server){
// Start SocketIO after app is initialized
app.sockets = require('./socket')(app,io);
console.log("Express server listening on port %d in %s mode", app.get('port'), app.settings.env);
});
*/