diff --git a/services/npm/npm-base.js b/services/npm/npm-base.js index 0263a5bbf6a41..4ce62bba1c59a 100644 --- a/services/npm/npm-base.js +++ b/services/npm/npm-base.js @@ -45,18 +45,22 @@ export default class NpmBase extends BaseJsonService { serviceKey: 'npm', } - static buildRoute(base, { withTag, queryParams } = {}) { + static buildRoute(base, { withTag, additionalQueryParamSchema } = {}) { if (withTag) { return { base, pattern: ':scope(@[^/]+)?/:packageName/:tag*', - queryParamSchema: queryParams || queryParamSchema, + queryParamSchema: additionalQueryParamSchema + ? queryParamSchema.append(additionalQueryParamSchema) + : queryParamSchema, } } else { return { base, pattern: ':scope(@[^/]+)?/:packageName', - queryParamSchema: queryParams || queryParamSchema, + queryParamSchema: additionalQueryParamSchema + ? queryParamSchema.append(additionalQueryParamSchema) + : queryParamSchema, } } } diff --git a/services/npm/npm-last-update.service.js b/services/npm/npm-last-update.service.js index 0b106a8af0fce..758df8722e70b 100644 --- a/services/npm/npm-last-update.service.js +++ b/services/npm/npm-last-update.service.js @@ -1,16 +1,10 @@ import Joi from 'joi' import dayjs from 'dayjs' -import { optionalUrl } from '../validators.js' import { InvalidParameter, pathParam, queryParam } from '../index.js' import { formatDate } from '../text-formatters.js' import { age as ageColor } from '../color-formatters.js' import NpmBase, { packageNameDescription } from './npm-base.js' -const queryParamSchema = Joi.object({ - registry_uri: optionalUrl, - version: Joi.string(), -}).required() - const updateResponseSchema = Joi.object({ time: Joi.object({ modified: Joi.string().required(), @@ -19,12 +13,16 @@ const updateResponseSchema = Joi.object({ .required(), }).required() +const additionalQueryParamSchema = { + version: Joi.string(), +} + export class NpmLastUpdate extends NpmBase { static category = 'activity' static route = this.buildRoute('npm/last-update', { withTag: false, - queryParams: queryParamSchema, + additionalQueryParamSchema, }) static openApi = {