From 096eaa92f431b5a08a11860b2a84da4760906ed0 Mon Sep 17 00:00:00 2001 From: kevin olson Date: Tue, 7 Jan 2025 00:07:35 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20coding=20blind=20at=20this=20poi?= =?UTF-8?q?nt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/runtime/server/utils/metapi.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/runtime/server/utils/metapi.ts b/src/runtime/server/utils/metapi.ts index 014ed16..55d1f1e 100644 --- a/src/runtime/server/utils/metapi.ts +++ b/src/runtime/server/utils/metapi.ts @@ -1,4 +1,5 @@ -import type { MetapiDetail, MetapiResponse } from '#api-utils' +import { setResponseStatus } from 'h3' +import type { H3Event } from 'h3' let start: number | undefined @@ -7,7 +8,7 @@ const bench = (): string => { return start ? `${(end - start).toFixed(3)}ms` : 'n/a' } -const render = (data: unknown): MetapiResponse => { +const render = (data: unknown): import('#api-utils').MetapiResponse => { return { meta: { benchmark: bench(), @@ -17,7 +18,7 @@ const render = (data: unknown): MetapiResponse => { } } -const success = (message: string, data?: unknown): MetapiResponse => { +const success = (message: string, data?: unknown): import('#api-utils').MetapiResponse => { return { meta: { benchmark: bench(), @@ -28,7 +29,7 @@ const success = (message: string, data?: unknown): MetapiResponse => { } } -const error = (event: unknown, detail: MetapiDetail, code: number = 400): MetapiResponse => { +const error = (event: H3Event, detail: import('#api-utils').MetapiDetail, code: number = 400): import('#api-utils').MetapiResponse => { setResponseStatus(event, code) return { meta: { @@ -40,9 +41,9 @@ const error = (event: unknown, detail: MetapiDetail, code: number = 400): Metapi } } -const notFound = (event: unknown): MetapiResponse => error(event, 'Not Found', 404) +const notFound = (event: H3Event): import('#api-utils').MetapiResponse => error(event, 'Not Found', 404) -const renderNullError = (event: unknown, data: unknown): MetapiResponse => { +const renderNullError = (event: H3Event, data: unknown): import('#api-utils').MetapiResponse => { if (data === null) return error(event, 'Not Found', 404) return render(data) }