Skip to content

Commit

Permalink
feat: new type RuntimeAdapterTarget
Browse files Browse the repository at this point in the history
  • Loading branch information
magne4000 committed Dec 9, 2024
1 parent 1c0756b commit 8768e6d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,21 +213,23 @@ export type Adapter =
| WebrouteAdapter
| OtherAdapter;
export type RuntimeAdapter = Runtime & Adapter;
export type RuntimeAdapterTarget<T> = T extends string ? Runtime & Extract<Adapter, { adapter: T }> : RuntimeAdapter;

export type UniversalMiddleware<
InContext extends Universal.Context = Universal.Context,
OutContext extends Universal.Context = Universal.Context,
Target = unknown,
> = (
request: Request,
context: InContext,
runtime: RuntimeAdapter,
runtime: RuntimeAdapterTarget<Target>,
// biome-ignore lint/suspicious/noConfusingVoidType: <explanation>
) => Awaitable<Response | OutContext | ((response: Response) => Awaitable<Response>) | void | undefined>;

export type UniversalHandler<InContext extends Universal.Context = Universal.Context> = (
export type UniversalHandler<InContext extends Universal.Context = Universal.Context, Target = unknown> = (
request: Request,
context: InContext,
runtime: RuntimeAdapter,
runtime: RuntimeAdapterTarget<Target>,
) => Awaitable<Response>;

export type Get<T extends unknown[], U> = (...args: T) => U;

0 comments on commit 8768e6d

Please sign in to comment.