54 lines
1.7 KiB
JavaScript
54 lines
1.7 KiB
JavaScript
|
"use strict";
|
||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||
|
};
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
var consts_1 = __importDefault(require("@scode/consts"));
|
||
|
var Status = /** @class */ (function () {
|
||
|
function Status() {
|
||
|
this._status = -1;
|
||
|
}
|
||
|
Object.defineProperty(Status.prototype, "status", {
|
||
|
get: function () {
|
||
|
if (this._status === -1)
|
||
|
throw new Error('status undefined');
|
||
|
return this._status;
|
||
|
},
|
||
|
set: function (value) {
|
||
|
this._status = value;
|
||
|
},
|
||
|
enumerable: true,
|
||
|
configurable: true
|
||
|
});
|
||
|
Object.defineProperty(Status.prototype, "has_status", {
|
||
|
get: function () {
|
||
|
return this._status !== -1;
|
||
|
},
|
||
|
enumerable: true,
|
||
|
configurable: true
|
||
|
});
|
||
|
/*
|
||
|
* Status setters
|
||
|
*/
|
||
|
Status.prototype.ok = function () {
|
||
|
this._status = consts_1.default.status_ok;
|
||
|
};
|
||
|
Status.prototype.ok_no_content = function () {
|
||
|
this._status = consts_1.default.status_ok_no_content;
|
||
|
};
|
||
|
Status.prototype.bad_request = function () {
|
||
|
this._status = consts_1.default.status_bad_request;
|
||
|
};
|
||
|
Status.prototype.unauthorized = function () {
|
||
|
this._status = consts_1.default.status_unauthorized;
|
||
|
};
|
||
|
Status.prototype.forbidden = function () {
|
||
|
this._status = consts_1.default.status_forbidden;
|
||
|
};
|
||
|
Status.prototype.not_found = function () {
|
||
|
this._status = consts_1.default.status_not_found;
|
||
|
};
|
||
|
return Status;
|
||
|
}());
|
||
|
exports.default = Status;
|