Skip to content

Commit

Permalink
Merge branch 'master' of github.com:krausest/js-framework-benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
krausest committed Dec 30, 2022
2 parents 0d87866 + 13070dc commit 00d619f
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 47 deletions.
32 changes: 30 additions & 2 deletions server/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
const express = require('express')
const bodyParser = require('body-parser')
const path = require('path')
const fs = require('fs');
const fsp = require('fs/promises');

const app = express()
const port = 8080

const addCSP = false;

app.use(express.json());

let frameworkDirectory = path.join(__dirname, "..", "frameworks");
let webDriverResultDirectory = path.join(__dirname, "..", "webdriver-ts-results");

Expand Down Expand Up @@ -104,7 +109,15 @@ function addSiteIsolationForIndex(request, response, next) {
}
app.use(addSiteIsolationForIndex);

app.use('/frameworks', express.static(frameworkDirectory))
app.use('/frameworks', express.static(frameworkDirectory,
{
setHeaders: function(res, path) {
if (addCSP) {
res.setHeader('Content-Security-Policy', "default-src 'self'; report-uri /csp");
}
}
}
))
app.use('/webdriver-ts-results', express.static(webDriverResultDirectory))
app.use('/css', express.static(path.join(frameworkDirectory, '..', 'css')))
app.get('/index.html', async (req, res, next) => {
Expand All @@ -117,8 +130,23 @@ app.get('/ls', async (req, res) => {
let t1 = Date.now();
console.log("/ls duration ", (t1-t0));
})
app.use('/csp', bodyParser.json({ type: 'application/csp-report' }))

violations = []

app.post('/csp', async (req, res) => {
console.log("/CSP ", req.body);
let uri = req.body['csp-report']["document-uri"]
let frameworkRegEx = /((non-)?keyed\/.*?\/)/
violations.push(uri.match(frameworkRegEx)[0])
res.sendStatus(201);
})

app.get('/csp', async (req, res) => {
res.send(violations)
})


app.listen(port, () => {
console.log(`Server running on port ${port}`)
console.log(`Server running on port ${port}`);
})
85 changes: 77 additions & 8 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.20.1",
"express": "^4.18.1"
},
"devDependencies": {
Expand Down
70 changes: 35 additions & 35 deletions webdriver-ts-results/src/results.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion webdriver-ts-results/table.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion webdriver-ts/results.json

Large diffs are not rendered by default.

0 comments on commit 00d619f

Please sign in to comment.