typerinth
Version:
A TypeScript library for interacting with the Modrinth API.
31 lines (30 loc) • 1.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const Route_1 = require("../Route");
const errors_1 = require("../../errors");
class GetUserProjectsRoute extends Route_1.Route {
userId;
constructor(baseUrl, ua, cacheManager, userId) {
super(baseUrl, ua, cacheManager);
this.userId = userId;
}
getCacheKey() {
return `user_projects:${this.userId}`;
}
getUrl() {
return Route_1.Route.addPathSegment(this.baseUrl, `/user/${this.userId}/projects`);
}
parseData(data) {
if (data === null)
throw new errors_1.UserProjectsNotFoundError('User projects not found');
if (!data)
throw new errors_1.UnexpectedApiError('Unexpected empty response');
if (data.error) {
if (data.error === 'not_found')
throw new errors_1.UserProjectsNotFoundError('User projects not found');
throw new errors_1.ApiError(data.error, data.description);
}
return data;
}
}
exports.default = GetUserProjectsRoute;