diff --git a/services/freecodecamp/freecodecamp-points.service.js b/services/freecodecamp/freecodecamp-points.service.js index 54630c25ef530b8166638e191577db95da817419..bf1a16973f1fc4a4f6c29ba396fd8c43e8ccbda0 100644 --- a/services/freecodecamp/freecodecamp-points.service.js +++ b/services/freecodecamp/freecodecamp-points.service.js @@ -1,11 +1,6 @@ import Joi from 'joi' import { metric } from '../text-formatters.js' -import { - BaseJsonService, - InvalidResponse, - NotFound, - pathParams, -} from '../index.js' +import { BaseJsonService, InvalidResponse, pathParams } from '../index.js' /** * Validates that the schema response is what we're expecting. @@ -21,7 +16,7 @@ const schema = Joi.object({ .pattern(/^[a-zA-Z0-9\-_+]*$/, { points: Joi.number().allow(null).required(), }), - }).optional(), + }).required(), }).required() /** @@ -62,18 +57,18 @@ export default class FreeCodeCampPoints extends BaseJsonService { username, }, }, + httpErrors: { 404: 'profile not found' }, }) } static transform(response, username) { const { entities } = response - if (entities === undefined) - throw new NotFound({ prettyMessage: 'profile not found' }) - const { points } = entities.user[username] - if (points === null) throw new InvalidResponse({ prettyMessage: 'private' }) + if (points === null) { + throw new InvalidResponse({ prettyMessage: 'private' }) + } return points }