-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
29 lines (27 loc) · 973 Bytes
/
Copy pathserver.js
File metadata and controls
29 lines (27 loc) · 973 Bytes
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
/**
* @author Adam Barreiro <adambarreiro@gmail.com>
*
* See GitHub repo for more info:
* https://github.com/adambarreiro/socket-chat
* -------------------------------------------------------------------------------------
*
* Server core module. Initializes all the middleware and modules.
*/
var express = require('express');
var app = express();
var logger = require('morgan');
var path = require('path');
var bodyParser = require('body-parser');
var http = require('http').Server(app);
var io = require('socket.io')(http);
var router = require('./routes/index');
var chat = require('./chat/chat');
app.use(logger('dev'));
app.use(bodyParser.urlencoded({extended: true}));
app.use(express.static(path.join(__dirname,'public')));
app.use('/bower_components', express.static(path.join(__dirname,'bower_components')));
router(app);
chat(io);
http.listen(process.env.PORT || 8080, function(){
console.log('CHAT SERVER STARTED:' + (process.env.PORT || 8080));
});