This commit is contained in:
Anton Bracke
2019-05-03 00:21:10 +02:00
commit 7d027b561d
14 changed files with 3969 additions and 0 deletions

45
testserver/index.js Normal file
View File

@@ -0,0 +1,45 @@
const express = require('express');
const expressStatus = require('express-status-monitor');
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const app = express();
app.use(expressStatus());
app.get('/', (req, res) => {
res.send('Hello world');
});
app.get('/regex', (req, res) => {
const userAgent = `aaaa${req.headers['user-agent']}`;
res.send(`greedy regex (a+)+ ${(/(a+)+/).test(userAgent)}`);
});
app.get('/crypto', (req, res) => {
const buf = crypto.randomBytes(256);
res.send(`crypto.randomBytes(256): ${buf}`);
});
app.get('/file', (req, res) => {
const hash = crypto.createHash('sha512');
const filename = path.resolve(__dirname, 'package-lock.json');
const stream = fs.ReadStream(filename);
const randomString = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
hash.update(randomString);
stream.on('data', (data) => {
hash.update(data);
});
// making digest
stream.on('end', () => {
res.send(`file hash: ${hash.digest('hex')}`);
});
});
app.listen(3000, () => {
console.log('Test server on port 3000!');
});

1080
testserver/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

17
testserver/package.json Normal file
View File

@@ -0,0 +1,17 @@
{
"name": "testserver",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"express": "^4.16.4",
"express-status-monitor": "^1.2.5"
},
"devDependencies": {},
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}