1 |
|
2 |
|
3 |
|
4 | 'use strict';
|
5 |
|
6 | const Base = require('../base/Component');
|
7 |
|
8 | module.exports = class BodyParser extends Base {
|
9 |
|
10 | constructor (config) {
|
11 | super({
|
12 | depends: '#start',
|
13 | ...config
|
14 | });
|
15 | this.jsonParser = bodyParser.json();
|
16 | this.urlencodeParser = bodyParser.urlencoded(config);
|
17 | }
|
18 |
|
19 | init () {
|
20 | this.module.addHandler('use', this.jsonParser);
|
21 | this.module.addHandler('use', this.urlencodeParser);
|
22 | }
|
23 | };
|
24 |
|
25 | const bodyParser = require('body-parser'); |
\ | No newline at end of file |