Skip to content

Commit

Permalink
fix: ensure legacy hook types are populated (#2725)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Sep 11, 2024
1 parent fc6c2fa commit 7dc8ae5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
18 changes: 18 additions & 0 deletions src/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import type { AppOptions, H3Event } from "h3";
import type {
CaptureError,
NitroConfig,
NitroOpenAPIConfig,
NitroRouteConfig,
RenderResponse,
} from "nitropack/types";

// Core
Expand Down Expand Up @@ -67,6 +70,21 @@ export interface NitroRuntimeConfig {
[key: string]: any;
}

/** @deprecated Use `NitroRuntimeHooks` from `nitropack/types` */
export interface NitroRuntimeHooks {
close: () => void;
error: CaptureError;

request: NonNullable<AppOptions["onRequest"]>;
beforeResponse: NonNullable<AppOptions["onBeforeResponse"]>;
afterResponse: NonNullable<AppOptions["onAfterResponse"]>;

"render:response": (
response: Partial<RenderResponse>,
context: { event: H3Event }
) => void;
}

/** @deprecated Use `NitroRuntimeConfigApp` from `nitropack/types` */
export interface NitroRuntimeConfigApp {
baseURL: string;
Expand Down
17 changes: 3 additions & 14 deletions src/types/runtime/nitro.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { AppOptions, App as H3App, H3Event, Router } from "h3";
import type { App as H3App, H3Event, Router } from "h3";
import type { Hookable } from "hookable";
import type { NitroRuntimeHooks as NitroTypesRuntimeHooks } from "nitropack";
import type {
createCall,
createFetch as createLocalFetch,
Expand Down Expand Up @@ -43,16 +44,4 @@ export type CaptureError = (
context: CapturedErrorContext
) => void;

export interface NitroRuntimeHooks {
close: () => void;
error: CaptureError;

request: NonNullable<AppOptions["onRequest"]>;
beforeResponse: NonNullable<AppOptions["onBeforeResponse"]>;
afterResponse: NonNullable<AppOptions["onAfterResponse"]>;

"render:response": (
response: Partial<RenderResponse>,
context: { event: H3Event }
) => void;
}
export interface NitroRuntimeHooks extends NitroTypesRuntimeHooks {}

0 comments on commit 7dc8ae5

Please sign in to comment.