-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.js
72 lines (55 loc) · 1.62 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* Slab-Fondler server
*
* A static server for content
* and a socket.io module for data transfer
*
* @author Belin Fieldson @thebelin
* @copyright GPL-V3
*
* ENV vars:
* COOKIE_SECRET
* HTTP_PORT
*/
"use strict";
// Express Framework
const express = require('express');
// App object is express library as a function
const app = express();
// Filesystem object
const fs = require('fs');
// socketio module
const socket = require('socket.io');
// Set the port to env setting or default
const port = process.env.PORT || 80;
// Express http server
const httpServer = require('http');
// Compression middleware
const compression = require('compression');
// The logger object
const morgan = require('morgan');
// Parsers for incoming data
const bodyParser = require('body-parser');
// set up express application logging
app.use(morgan('dev'));
// Read form vars
app.use(bodyParser.urlencoded({
extended: true,
limit: '1024mb',
parameterLimit: 1000000
}));
// get information from html forms
app.use(bodyParser.json({limit: '1024mb'}));
// Compression module speeds get requests
app.use(compression());
// Make the http folder available as the root, to deliver the static content
app.use('/', require('express').static('static'));
// make the screenfull dist folder available to the user
app.use('/screenfull', require('express').static('node_modules/screenfull/dist'));
console.log('starting http server on port ' + port);
// Start the HTTP listener on http
const server = httpServer.Server(app);
const io = require('socket.io')(server);
server.listen(port);
// Run the socketio interface
require ('./socketservice.js')(io);