@anot/http-response-builder
Version:
A robust and type-safe library for constructing HTTP responses with optional paging and metadata. Designed for TypeScript and JavaScript, it ensures correct typing while simplifying the creation of various HTTP response types.
34 lines (33 loc) • 1.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CurrentUser = void 0;
var CurrentUser = /** @class */ (function () {
function CurrentUser(idUser) {
this.setCurrentUserId(idUser);
}
CurrentUser.prototype.setExtraData = function (extraData) {
if (typeof extraData !== 'object' || extraData === null || Array.isArray(extraData)) {
throw new TypeError('Invalid metadata: Metadata must be a non-null object');
}
this.extraData = extraData;
return this;
};
CurrentUser.prototype.setCurrentUserId = function (idUser) {
if (idUser !== null && idUser !== undefined) {
if (typeof idUser === 'string' || typeof idUser === "number") {
this.idUser = idUser;
return this;
}
throw new TypeError("Invalid type for idUser, expected a string or a number");
}
return this;
};
CurrentUser.prototype.getCurrentUserId = function () {
return this.idUser;
};
CurrentUser.prototype.getExtraData = function () {
return this.extraData;
};
return CurrentUser;
}());
exports.CurrentUser = CurrentUser;