diff --git a/server/api/health/controller.ts b/server/api/health/controller.ts index 612a14f..19621b5 100644 --- a/server/api/health/controller.ts +++ b/server/api/health/controller.ts @@ -12,19 +12,10 @@ const throwCustomError = (label: string) => (e: Error) => { export default defineController(() => ({ get: async () => ({ status: 200, - body: { - server: 'ok', - db: await prismaClient.$queryRaw`SELECT CURRENT_TIMESTAMP;` - .then(() => 'ok' as const) - .catch(throwCustomError('DB')), - s3: await s3 - .health() - .then(() => 'ok' as const) - .catch(throwCustomError('S3')), - cognito: await cognito - .health() - .then(() => 'ok' as const) - .catch(throwCustomError('Cognito')), - }, + body: await Promise.all([ + prismaClient.$queryRaw`SELECT CURRENT_TIMESTAMP;`.catch(throwCustomError('DB')), + s3.health().catch(throwCustomError('S3')), + cognito.health().catch(throwCustomError('Cognito')), + ]).then(() => 'ok'), }), })); diff --git a/server/api/health/index.ts b/server/api/health/index.ts index 30554d9..d365dc0 100644 --- a/server/api/health/index.ts +++ b/server/api/health/index.ts @@ -2,6 +2,6 @@ import type { DefineMethods } from 'aspida'; export type Methods = DefineMethods<{ get: { - resBody: Record<'server' | 'db' | 's3' | 'cognito', 'ok'>; + resBody: 'ok'; }; }>; diff --git a/server/tests/api/public.test.ts b/server/tests/api/public.test.ts index 082c16e..82c2409 100644 --- a/server/tests/api/public.test.ts +++ b/server/tests/api/public.test.ts @@ -16,9 +16,7 @@ test(GET(noCookieClient.health), async () => { const apiClient = await createCognitoUserClient(); const res = await apiClient.health.$get(); - expect(res.server).toEqual('ok'); - expect(res.db).toEqual('ok'); - expect(res.s3).toEqual('ok'); + expect(res).toEqual('ok'); }); test(POST(noCookieClient.session), async () => {