diff --git a/apps/server/src/endpoints/pips/estimates.endpoint.ts b/apps/server/src/endpoints/pips/estimates.endpoint.ts index 5fca460..98e8fdf 100644 --- a/apps/server/src/endpoints/pips/estimates.endpoint.ts +++ b/apps/server/src/endpoints/pips/estimates.endpoint.ts @@ -45,12 +45,6 @@ FASTIFY.server.post('/pips/estimates', async (request, reply) => return reply.code(400).send([]); } - const regexPatternForStopId = /^\d{6}$/; // Match a string with exactly 6 numeric digits - const allStopIdsAreValid = request.body.stops.every(stopId => regexPatternForStopId.test(stopId)); - if (!allStopIdsAreValid) { - return reply.code(400).send([]); - } - // // Loop through each stop in the request to check for special cases @@ -187,6 +181,12 @@ FASTIFY.server.post('/pips/estimates', async (request, reply) => } } + const regexPatternForStopId = /^\d{6}$/; // Match a string with exactly 6 numeric digits + const allStopIdsAreValid = request.body.stops.every(stopId => regexPatternForStopId.test(stopId)); + if (!allStopIdsAreValid) { + return reply.code(400).send([]); + } + // // Request PCGI API for the estimated arrival times for the stops in the request