-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
38 lines (29 loc) · 912 Bytes
/
server.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
/* jshint node: true */
'use strict';
var express = require('express');
var browserify = require('browserify-middleware');
var path = require('path');
var app = express();
// all environments
app.set('port', process.env.NODE_PORT || 1337);
app.use(app.router);
app.use('/js', browserify(path.join(__dirname, 'public/js'), {
minify: false,
debug: true
}));
app.use(express.static(path.join(__dirname, 'public')));
// development only
if ('development' == app.get('env')) {
app.use(express.errorHandler());
}
// serve front-end files
var server = require('http').Server(app);
var switchboard = require('rtc-switchboard')(server);
app.get('/rtc.io/primus.js', switchboard.library());
// start the server
server.listen(app.get('port'), function(err) {
if (err) {
return console.log('Encountered error starting server: ', err);
}
console.log('server running on port ' + app.get('port'));
});