-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.safe.js
More file actions
37 lines (28 loc) · 830 Bytes
/
index.safe.js
File metadata and controls
37 lines (28 loc) · 830 Bytes
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
var express = require('express');
var app = express();
const port = 3000
const helmet = require('helmet')
var bodyParser = require('body-parser')
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
// parse application/json
app.use(bodyParser.json())
app.use(helmet())
app.use(helmet.contentSecurityPolicy({
directives: {
defaultSrc: ["'self'"],
styleSrc: ["'self'", 'maxcdn.bootstrapcdn.com']
}
}))
app.post('/test', (req, res) => {
var obj = req.body
if (!(obj instanceof Array)) {
res.end('error')
return
}
for (let index = 0; index < obj.length; index++) {
const element = obj.length[index];
}
res.end('finished')
})
app.listen(port, () => console.log(`Example app listening on port ${port}!`))