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.
85 lines • 2.44 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Request = void 0;
const qs_1 = require("qs");
const RequestHeader_1 = require("./RequestHeader");
const config_1 = require("../config/config");
const parseurl_1 = __importDefault(require("parseurl"));
class Request {
constructor(nodeReq, parsedBody, params) {
var _a;
this.nodeReq = nodeReq;
this._pathname = null;
this.header = new RequestHeader_1.RequestHeader(nodeReq);
this.query = qs_1.parse(parseurl_1.default(nodeReq).query, (_a = config_1.config.web) === null || _a === void 0 ? void 0 : _a.querystring);
this.body = parsedBody ? parsedBody.fields : {};
this.pathname = parseurl_1.default(this.nodeReq).pathname;
this._params = params;
}
get body() {
return this._body;
}
set body(body) {
this._body = body;
}
get params() {
return this._params;
}
set params(params) {
this._params = params;
}
get query() {
return this._query;
}
set query(query) {
this._query = query;
}
get querystring() {
return qs_1.stringify(this._query);
}
set querystring(querystring) {
var _a;
this.query = qs_1.parse(querystring, (_a = config_1.config.web) === null || _a === void 0 ? void 0 : _a.querystring);
}
get search() {
if (!this.querystring.length) {
return '';
}
return `?${this.querystring}`;
}
get url() {
return this.nodeReq.url;
}
set url(url) {
this.nodeReq.url = url;
}
get httpMethod() {
return this.nodeReq.method.toLowerCase();
}
set httpMethod(httpMethod) {
this.nodeReq.method = httpMethod;
}
get pathname() {
return this._pathname;
}
set pathname(pathname) {
this._pathname = pathname;
}
get httpVersion() {
return this.nodeReq.httpVersion.toLowerCase();
}
get httpVersionMajor() {
return this.nodeReq.httpVersionMajor;
}
get httpVersionMinor() {
return this.nodeReq.httpVersionMinor;
}
get socket() {
return this.nodeReq.socket;
}
}
exports.Request = Request;
//# sourceMappingURL=Request.js.map