39 lines
1.1 KiB
JavaScript
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;
|