-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
52 lines (45 loc) · 1.17 KB
/
index.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
const Hapi = require('@hapi/hapi');
// const socket = require('socket.io')
const socket = require('socket.io');
// const content = require('fs').readFileSync(__dirname + '/temp.html', 'utf8');
// const content = require('fs').readFileSync('/home/iauro/zzzz/workworkwork/pocs and stuff/ResumableFileUploader/resumeUpload-ui/src/index.html', 'utf8');
const socketIO = require('./socket.js');
let serverConnectionOptions = {
port: 3000,
host: 'localhost',
state: {
strictHeader: false,
ignoreErrors: true
},
routes: {
cors: true,
timeout: {
server: 1200000, // 1,200,000 or 20 minutes
socket: 1300000
}
}
};
const server = new Hapi.Server(serverConnectionOptions);
const io = socket(server.listener, {
cors: {
origin: '*',
methods: ["GET", "POST"],
allowedHeaders: ["authorization"],
credentials: true
}
});
const endpoints = {
method: 'GET',
path: '/',
handler: function (request, h) {
return null;
}
}
server.route(endpoints);
server.start();
server.events.on('start', (route) => {
console.log('Node server is running on ==> ', server.info.uri);
});
io.sockets.on('connection', socket => {
socketIO(socket);
});