-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
30 lines (23 loc) · 781 Bytes
/
Copy pathserver.js
File metadata and controls
30 lines (23 loc) · 781 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
30
/* global config */
import { createServer } from 'http';
import socketIo from 'socket.io';
import App from './app';
import sockets from './bootstrap/sockets';
class Server {
constructor(app) {
const server = createServer(app);
const port = config.app.port;
const host = config.app.host;
const url = (config.app.env === 'production')
? config.app.url
: `${config.app.url}:${port}`;
// Socket configuration
const io = socketIo(server);
sockets(io);
server.listen(port, host, () => {
console.log(`Server listening on ${url} at port ${port}, Ctrl+C to stop`);
});
return server;
}
}
export const server = new Server(App());