diff --git a/packages/jobs/lib/routes/postIdle.ts b/packages/jobs/lib/routes/postIdle.ts index c6721b5a9bc..c76830dc661 100644 --- a/packages/jobs/lib/routes/postIdle.ts +++ b/packages/jobs/lib/routes/postIdle.ts @@ -31,9 +31,11 @@ const handler = async (req: EndpointRequest, res: EndpointResponse, res: EndpointResponse, res: EndpointResponse if (register.isErr()) { throw register.error; } - return res.status(200).json({ status: 'ok' }); + res.status(200).json({ status: 'ok' }); + return; } catch (err) { - return res.status(500).json({ error: { code: 'register_failed', message: err instanceof Error ? err.message : 'failed to register runner' } }); + res.status(500).json({ error: { code: 'register_failed', message: err instanceof Error ? err.message : 'failed to register runner' } }); + return; } }; diff --git a/packages/orchestrator/lib/routes/getHealth.ts b/packages/orchestrator/lib/routes/getHealth.ts index a179c9bf2b8..4d5dc8c30e7 100644 --- a/packages/orchestrator/lib/routes/getHealth.ts +++ b/packages/orchestrator/lib/routes/getHealth.ts @@ -14,5 +14,7 @@ export const routeHandler: RouteHandler = { path, method, validate: (_req, _res, next) => next(), // No extra validation needed - handler: (_req, res) => res.status(200).json({ status: 'ok' }) + handler: (_req, res) => { + res.status(200).json({ status: 'ok' }); + } }; diff --git a/packages/orchestrator/lib/routes/v1/postImmediate.ts b/packages/orchestrator/lib/routes/v1/postImmediate.ts index d63be164a84..c7b01cc6293 100644 --- a/packages/orchestrator/lib/routes/v1/postImmediate.ts +++ b/packages/orchestrator/lib/routes/v1/postImmediate.ts @@ -88,9 +88,11 @@ const handler = (scheduler: Scheduler) => { heartbeatTimeoutSecs: req.body.timeoutSettingsInSecs.heartbeat }); if (task.isErr()) { - return res.status(500).json({ error: { code: 'immediate_failed', message: task.error.message } }); + res.status(500).json({ error: { code: 'immediate_failed', message: task.error.message } }); + return; } - return res.status(200).json({ taskId: task.value.id }); + res.status(200).json({ taskId: task.value.id }); + return; }; }; diff --git a/packages/orchestrator/lib/routes/v1/postRecurring.ts b/packages/orchestrator/lib/routes/v1/postRecurring.ts index 6c806a78fc0..270a3f6025e 100644 --- a/packages/orchestrator/lib/routes/v1/postRecurring.ts +++ b/packages/orchestrator/lib/routes/v1/postRecurring.ts @@ -73,9 +73,11 @@ const handler = (scheduler: Scheduler) => { lastScheduledTaskId: null }); if (schedule.isErr()) { - return res.status(500).json({ error: { code: 'recurring_failed', message: schedule.error.message } }); + res.status(500).json({ error: { code: 'recurring_failed', message: schedule.error.message } }); + return; } - return res.status(200).json({ scheduleId: schedule.value.id }); + res.status(200).json({ scheduleId: schedule.value.id }); + return; }; }; diff --git a/packages/orchestrator/lib/routes/v1/putRecurring.ts b/packages/orchestrator/lib/routes/v1/putRecurring.ts index 311317afef2..283b92bbb0e 100644 --- a/packages/orchestrator/lib/routes/v1/putRecurring.ts +++ b/packages/orchestrator/lib/routes/v1/putRecurring.ts @@ -48,12 +48,15 @@ const handler = (scheduler: Scheduler) => { updatedSchedule = await scheduler.setScheduleFrequency({ scheduleName: schedule.name, frequencyMs: schedule.frequencyMs }); } if (!updatedSchedule) { - return res.status(400).json({ error: { code: 'put_recurring_failed', message: `invalid parameters: ${JSON.stringify(schedule)}` } }); + res.status(400).json({ error: { code: 'put_recurring_failed', message: `invalid parameters: ${JSON.stringify(schedule)}` } }); + return; } if (updatedSchedule.isErr()) { - return res.status(500).json({ error: { code: 'put_recurring_failed', message: updatedSchedule.error.message } }); + res.status(500).json({ error: { code: 'put_recurring_failed', message: updatedSchedule.error.message } }); + return; } - return res.status(200).json({ scheduleId: updatedSchedule.value.id }); + res.status(200).json({ scheduleId: updatedSchedule.value.id }); + return; }; }; diff --git a/packages/orchestrator/lib/routes/v1/schedules/postRun.ts b/packages/orchestrator/lib/routes/v1/schedules/postRun.ts index 1bbaa20dd0e..305d778925d 100644 --- a/packages/orchestrator/lib/routes/v1/schedules/postRun.ts +++ b/packages/orchestrator/lib/routes/v1/schedules/postRun.ts @@ -32,9 +32,11 @@ const handler = (scheduler: Scheduler) => { scheduleName: req.body.scheduleName }); if (schedule.isErr()) { - return res.status(500).json({ error: { code: 'recurring_run_failed', message: schedule.error.message } }); + res.status(500).json({ error: { code: 'recurring_run_failed', message: schedule.error.message } }); + return; } - return res.status(200).json({ scheduleId: schedule.value.id }); + res.status(200).json({ scheduleId: schedule.value.id }); + return; }; }; diff --git a/packages/orchestrator/lib/routes/v1/schedules/postSearch.ts b/packages/orchestrator/lib/routes/v1/schedules/postSearch.ts index 9a852194d66..bb784faec74 100644 --- a/packages/orchestrator/lib/routes/v1/schedules/postSearch.ts +++ b/packages/orchestrator/lib/routes/v1/schedules/postSearch.ts @@ -37,9 +37,11 @@ const handler = (scheduler: Scheduler) => { ...(names ? { names } : {}) }); if (getSchedules.isErr()) { - return res.status(500).json({ error: { code: 'search_failed', message: getSchedules.error.message } }); + res.status(500).json({ error: { code: 'search_failed', message: getSchedules.error.message } }); + return; } - return res.status(200).json(getSchedules.value); + res.status(200).json(getSchedules.value); + return; }; }; diff --git a/packages/orchestrator/lib/routes/v1/tasks/postSearch.ts b/packages/orchestrator/lib/routes/v1/tasks/postSearch.ts index 3480553ce88..c5b04f2a195 100644 --- a/packages/orchestrator/lib/routes/v1/tasks/postSearch.ts +++ b/packages/orchestrator/lib/routes/v1/tasks/postSearch.ts @@ -40,9 +40,11 @@ const handler = (scheduler: Scheduler) => { ...(limit ? { limit } : {}) }); if (getTasks.isErr()) { - return res.status(500).json({ error: { code: 'search_failed', message: getTasks.error.message } }); + res.status(500).json({ error: { code: 'search_failed', message: getTasks.error.message } }); + return; } - return res.status(200).json(getTasks.value); + res.status(200).json(getTasks.value); + return; }; }; diff --git a/packages/persist/lib/routes/getHealth.ts b/packages/persist/lib/routes/getHealth.ts index f6cb7b8aa7c..bacea1bdf02 100644 --- a/packages/persist/lib/routes/getHealth.ts +++ b/packages/persist/lib/routes/getHealth.ts @@ -14,5 +14,7 @@ export const routeHandler: RouteHandler = { path, method, validate: (_req, _res, next) => next(), - handler: (_req, res) => res.status(200).json({ status: 'ok' }) + handler: (_req, res) => { + res.status(200).json({ status: 'ok' }); + } }; diff --git a/packages/utils/lib/express/route.ts b/packages/utils/lib/express/route.ts index a26b748361d..4627511ba0d 100644 --- a/packages/utils/lib/express/route.ts +++ b/packages/utils/lib/express/route.ts @@ -12,7 +12,7 @@ export interface Route> { export interface RouteHandler> extends Route { validate: (req: EndpointRequest, res: EndpointResponse, next: NextFunction) => void; - handler: (req: EndpointRequest, res: EndpointResponse, next: NextFunction) => void; + handler: (req: EndpointRequest, res: EndpointResponse, next: NextFunction) => void | Promise; } export const createRoute = >(server: Express, rh: RouteHandler): void => {