-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.ts
49 lines (28 loc) · 1.18 KB
/
app.ts
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
///<reference path='./lib/tslib/node.d.ts' />
///<reference path='./lib/tslib/express.d.ts' />
import express = require('express');
import http = require('http');
import path = require('path');
import routes = require('./config/routes');
import config = require('./config/config');
var app = express();
app.configure('development', function () {
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, './app/views'));
app.engine('html', require('ejs').renderFile);
app.use(express.favicon(path.join(__dirname, './app/public/favicon.ico')));
app.use(express.logger('dev'));
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.cookieParser());
});
routes.init(app);
var server = http.createServer(app).listen(app.get('port'), function () {
console.log('Express server listening on port ' + app.get('port'));
});
var io = require('socket.io').listen(server);
io.sockets.on('connection', function (socket) {
socket.emit('connected', "hello world!");
});