-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
36 lines (30 loc) · 1.22 KB
/
Copy pathserver.js
File metadata and controls
36 lines (30 loc) · 1.22 KB
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
// bring in the express module
var express = require("express");
// set up the environment variable to determine where we are depoloyed
var env = process.env.NODE_ENV = process.env.NODE_ENV || 'development';
// instantiate express
var app = express();
// bring in our config object and getting the correct object based on where we are deployed
var config = require('./server/config/config')[env];
// configure express based on where we are deployed...in here is where the stylus files get processed
require('./server/config/express')(app, config);
// connect to our database based on where we are deployed
require('./server/config/mongoose')(config);
// setup authentication and security
require('./server/config/passport')();
// set up the express routes
require('./server/config/routes')(app);
require('./server/config/errors')(app);
//app.listen(config.port);
app.set('port', config.port);
//app.listen(app.get('port'));
var server = require('http').Server(app);
var io = require('socket.io')(server);
server.listen(app.get('port'));
io.on('connection', function(socket){
socket.emit('news', {hello: 'world'});
socket.on('my other event', function(data){
console.log(data);
});
});
console.log('Listening on port ' + config.port + "...");