-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroutes.js
More file actions
37 lines (35 loc) · 1.17 KB
/
routes.js
File metadata and controls
37 lines (35 loc) · 1.17 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
const {domValidation} = require('./validator.js');
module.exports = (app) => {
// index route
app.get('/', (req, res) => {
res.json({"version": '0.0.1', name:"html-validator"});
});
app.post('/', (req, res) => {
/* TODO: Body should have:
{ cssContent: "encoded css in base64"
content: "encoded html in base64",
structureValidation: {
rootSelector: ,
elementsList: ['html', 'head', 'title', 'boby', 'div', 'h1'...],
valueValidations: [
{ selector: ,
expectedValues: [
[{attribute: ,
value: },
{attribute: ,
value: },..],
[{attribute: ,
value: },
{attribute: ,
value: },..],.. expected values elements selected should have
],
}
]
*/
const {body:{cssContent="", content, structureValidation, valueValidations}} = req;
const htmlText = Buffer.from(content, 'base64');
const cssText = Buffer.from(cssContent, 'base64');
const result = domValidation(htmlText, cssText, structureValidation, valueValidations);
res.json(result);
});
};