This repository has been archived on 2020-08-13. You can view files and clone it, but cannot push or open issues or pull requests.
requestor/dist/lib/classes/Transaction.js
2020-04-14 14:56:08 +02:00

39 lines
1.1 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var consts_1 = require("@scode/consts");
var Transaction = /** @class */ (function () {
/* constructor */
function Transaction(req, res) {
/* public */
this.status = -1;
this._req = req;
this._res = res;
}
Object.defineProperty(Transaction.prototype, "req", {
get: function () { return this._req; },
enumerable: true,
configurable: true
});
Object.defineProperty(Transaction.prototype, "res", {
get: function () { return this._res; },
enumerable: true,
configurable: true
});
Object.defineProperty(Transaction.prototype, "has_status", {
get: function () {
return Object.values(consts_1.http.status_codes)
.includes(this.status);
},
enumerable: true,
configurable: true
});
/* methods */
Transaction.prototype.finalize = function (data) {
if (this.has_status)
this._res.status(this.status);
this._res.end(data);
};
return Transaction;
}());
exports.default = Transaction;