-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
59 lines (36 loc) · 1.05 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const express = require('express');
const cors = require('cors');
const { socketController } = require('../sockets/controller');
class Server {
constructor() {
this.app = express();
this.port = process.env.PORT;
this.server = require('http').createServer( this.app );
this.io = require('socket.io')( this.server );
this.paths = {};
// Middlewares
this.middlewares();
// Rutas de mi aplicación
this.routes();
// Sockets
this.sockets();
}
middlewares() {
// CORS
this.app.use( cors() );
// Directorio Público
this.app.use( express.static('public') );
}
routes() {
// this.app.use( this.paths.auth, require('../routes/auth'));
}
sockets() {
this.io.on('connection', socketController );
}
listen() {
this.server.listen( this.port, () => {
console.log('Servidor corriendo en puerto', this.port );
});
}
}
module.exports = Server;