UNPKG

zents

Version:

ZenTS is a Node.js & TypeScript MVC-Framework for building rich web applications, released as free and open-source software under the MIT License. It is designed for building web applications with modern tools and design patterns.

34 lines 2.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BodyParser = void 0; const formidable_1 = require("formidable"); const config_1 = require("../config/config"); const os_1 = require("os"); class BodyParser extends formidable_1.IncomingForm { constructor() { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w; super(); this.encoding = (_c = (_b = (_a = config_1.config.web) === null || _a === void 0 ? void 0 : _a.bodyParser) === null || _b === void 0 ? void 0 : _b.encoding) !== null && _c !== void 0 ? _c : 'utf-8'; this.maxFields = (_f = (_e = (_d = config_1.config.web) === null || _d === void 0 ? void 0 : _d.bodyParser) === null || _e === void 0 ? void 0 : _e.maxFields) !== null && _f !== void 0 ? _f : 1000; this.maxFieldsSize = (_j = (_h = (_g = config_1.config.web) === null || _g === void 0 ? void 0 : _g.bodyParser) === null || _h === void 0 ? void 0 : _h.maxFieldsSize) !== null && _j !== void 0 ? _j : 20 * 1024 * 1024; this.maxFileSize = (_m = (_l = (_k = config_1.config.web) === null || _k === void 0 ? void 0 : _k.bodyParser) === null || _l === void 0 ? void 0 : _l.maxFileSize) !== null && _m !== void 0 ? _m : 200 * 1024 * 1024; this.keepExtensions = (_q = (_p = (_o = config_1.config.web) === null || _o === void 0 ? void 0 : _o.bodyParser) === null || _p === void 0 ? void 0 : _p.keepExtensions) !== null && _q !== void 0 ? _q : false; this.uploadDir = (_t = (_s = (_r = config_1.config.web) === null || _r === void 0 ? void 0 : _r.bodyParser) === null || _s === void 0 ? void 0 : _s.uploadDir) !== null && _t !== void 0 ? _t : os_1.tmpdir(); this.multiples = (_w = (_v = (_u = config_1.config.web) === null || _u === void 0 ? void 0 : _u.bodyParser) === null || _v === void 0 ? void 0 : _v.multiples) !== null && _w !== void 0 ? _w : false; } async parse(req) { return new Promise((resolve, reject) => { super.parse(req, (err, fields, files) => { if (err) { return reject(err); } return resolve({ fields, files, }); }); }); } } exports.BodyParser = BodyParser; //# sourceMappingURL=BodyParser.js.map