typerinth
Version:
A TypeScript library for interacting with the Modrinth API.
28 lines (27 loc) • 886 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const Route_1 = require("../Route");
class GetLicenseRoute extends Route_1.Route {
licenseId;
constructor(baseUrl, ua, cacheManager, licenseId) {
super(baseUrl, ua, cacheManager);
this.licenseId = licenseId;
}
getCacheKey() {
return `license:${this.licenseId}`;
}
getUrl() {
return Route_1.Route.addPathSegment(this.baseUrl, `/tag/license/${this.licenseId}`);
}
parseData(data) {
if (!data)
throw new Error('Unexpected empty response');
if (data.error) {
if (data.error === 'not_found')
throw new Error('FullLicense not found');
throw new Error(`Unexpected error: ${data.error} (${data.description})`);
}
return data;
}
}
exports.default = GetLicenseRoute;