Total Complexity | 5 |
Complexity/F | 1.25 |
Lines of Code | 34 |
Function Count | 4 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import cors from 'cors'; |
||
2 | import bodyParser from 'body-parser'; |
||
3 | |||
4 | export default { |
||
5 | json : bodyParser.json({ |
||
6 | limit : 1024 * 1024, |
||
7 | type : [ 'txt', 'json' ], |
||
8 | verify : (req, res, buf) => { |
||
9 | try { |
||
10 | JSON.parse(buf); |
||
11 | } catch { |
||
12 | res.send({ |
||
13 | status : 0, |
||
14 | error : { |
||
15 | code : 'FORMAT_ERROR', |
||
16 | message : 'BROKEN_JSON' |
||
17 | } |
||
18 | }); |
||
19 | throw new Error('BROKEN_JSON'); |
||
20 | } |
||
21 | } |
||
22 | }), |
||
23 | arrays(req, res, next) { |
||
24 | const keys = Object.keys(req.query); |
||
25 | |||
26 | keys |
||
27 | .filter(key => req.query[key].includes(',')) |
||
28 | // eslint-disable-next-line no-param-reassign |
||
29 | .forEach(key => req.query[key] = req.query[key].split(',')); |
||
30 | |||
31 | return next(); |
||
32 | }, |
||
33 | urlencoded : bodyParser.urlencoded({ extended: true }), |
||
34 | cors : cors({ origin: '*' }) |
||
35 | }; |
||
36 |