-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.js
More file actions
53 lines (46 loc) · 1.9 KB
/
Copy pathrun.js
File metadata and controls
53 lines (46 loc) · 1.9 KB
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
/**
* Parallelix Test Server
* Use this to test the Parallelix Client Library
*
* @author Neurosell
* @version 1.0.0
* @license MIT
* @author Ilya Rastorguev
* @email start@ncommx.com
* @website https://ncommx.com
* @github https://github.com/Neurosell/parallelix
*/
/* Setup Express Server */
const express = require('express'); // Express Library
const limiter = require('express-rate-limit'); // Rate Limiter
const { xss } = require('express-xss-sanitizer'); // XSS Filters
const fs = require('fs'); // File System
/* Initialize Express App */
const app = express(); // Express App
const port = 8080; // Port
/* Setup Express Server */
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(express.static('client'));
/* Setup Rate Limiter */
app.use(limiter({
windowMs: 1 * 60 * 1000, // Limit Time (15 mins)
limit: 1000, // Limit
standardHeaders: 'draft-7', // draft-6: `RateLimit-*` headers; draft-7: combined `RateLimit` header
legacyHeaders: false // Use Legacy Headers
}));
/* Setup XSS Filters */
app.use(xss());
app.disable('x-powered-by');
/* Start Express Server */
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
/* Show About Page */
app.get('/', (req, res) => {
return res.send(fs.readFileSync(__dirname + '/client/index.html', 'utf8'));
});
/* Show Client Test Page */
app.get('/test/', (req, res) => {
return res.send(fs.readFileSync(__dirname + '/client/test.html', 'utf8'));
});