-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
40 lines (33 loc) · 970 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
39
40
// Server
var express = require('express');
var app = express();
var path = require('path');
var server = require('http').createServer(app);
var io = require('socket.io')(server);
var hipsterList = require('./public/js/hipsterList');
var bodyParser = require('body-parser');
//data
var port = process.env.PORT || 3000;
var db = new hipsterList();
// Server Set-up
app.set('view engine', 'html');
app.use(express.static(__dirname + '/public'))
app.use(bodyParser.urlencoded({'extended':'true'}));
app.use(bodyParser.json());
app.use(bodyParser.json({ type: 'application/vnd.api+json' }));
io.on('connection', function(socket) {
});
function Server(dBase) {
this.db = dBase;
}
Server.prototype.init = function(port, cBack) {
_this = this;
require('./routes/index')(app, _this.db, io);
server.listen(port, cBack);
};
if(!module.parent) {
new Server(db).init(port, function(){
console.log('Hipsters running at ' + port);
});
}
module.exports = Server;