@iredium/butterfly
Version:
Express API Framework
37 lines (36 loc) • 1.19 kB
JavaScript
;
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseResponse = void 0;
var BaseResponse = /** @class */ (function () {
function BaseResponse() {
this.statusCode = 200;
this.cookieArgs = [];
}
BaseResponse.prototype.status = function (status) {
this.statusCode = status;
return this;
};
BaseResponse.prototype.cookie = function (name) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
this.cookieArgs.push(__spreadArray([name], args));
return this;
};
BaseResponse.prototype.executeRender = function (res) {
res.status(this.statusCode);
for (var _i = 0, _a = this.cookieArgs; _i < _a.length; _i++) {
var cookieArg = _a[_i];
res.cookie.apply(res, cookieArg);
}
this.render(res);
};
return BaseResponse;
}());
exports.BaseResponse = BaseResponse;