UNPKG

617 BJavaScriptView Raw
1/**
2 * @copyright Copyright (c) 2019 Maxim Khorin <maksimovichu@gmail.com>
3 */
4'use strict';
5
6const Base = require('../base/Component');
7
8module.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
25const bodyParser = require('body-parser');
\No newline at end of file