UNPKG

typerinth

Version:

A TypeScript library for interacting with the Modrinth API.

27 lines (26 loc) 856 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const Route_1 = require("../Route"); const errors_1 = require("../../errors"); class GetAuthUserRoute extends Route_1.Route { constructor(baseUrl, ua, cacheManager, auhtorization) { super(baseUrl, ua, cacheManager, auhtorization); } getCacheKey() { return `authuser`; } getUrl() { return Route_1.Route.addPathSegment(this.baseUrl, `/user`); } parseData(data) { if (data === null) throw new errors_1.UserNotFoundError('User not found'); if (!data) throw new errors_1.UnexpectedApiError('Unexpected empty response'); if (data.error) { throw new errors_1.ApiError(data.error, data.description); } return data; } } exports.default = GetAuthUserRoute;