import { H3EventContext, H3Route, Middleware, WebSocketHooks } from "h3"; import { ServerRequest, ServerRequestContext } from "srvx"; import { NitroApp, ResolvedRouteRules } from "nitro/types"; import { MatchedRoute } from "rou3"; declare global { var __nitro__: Partial> | undefined; } export declare function useNitroApp(): NitroApp; export declare function useNitroHooks(): NonNullable; export declare function serverFetch(resource: string | URL | Request, init?: RequestInit, context?: ServerRequestContext | H3EventContext): Promise; export declare function resolveWebsocketHooks(req: ServerRequest): Promise>; export declare function fetch(resource: string | URL | Request, init?: RequestInit, context?: ServerRequestContext | H3EventContext): Promise; /** * Get the resolved route rules for a method and pathname. * * The result is memoized and shared, so treat it as read-only. */ export declare function getRouteRules(method: string, pathname: string): { routeRules: ResolvedRouteRules; }; /** * Middleware that runs the route-rule middleware (`redirect`, `headers`, * `cors`, ...) matched for the current request, except `cache` (see * `createCacheRuleMiddleware`). The composed chain is cached per memoized * match, so each distinct match is composed once. * * `event.context.routeRules` is assigned earlier, from `~findRoute`, so it is * populated for every middleware regardless of its position in the chain. */ export declare function createRouteRulesMiddleware(): Middleware; /** * Middleware that runs the `cache` route rule matched for the current request. * The rule dispatches the matched route handler itself, so it is registered * after global and routed middleware for them to run on cached routes too. * * The rule is matched by `createRouteRulesMiddleware`, on the same pathname as * the other rules, even if a middleware rewrites `event.url` in between. */ export declare function createCacheRuleMiddleware(): Middleware; /** * Middleware that runs the routed (`server/middleware/**` with a route) * middleware matched for the current request. Chains are cached by the identity * of the matched handlers (a trie keyed on the router's stable data slots), so * the cache is bounded by the number of distinct match combinations rather than * by request pathnames. */ export declare function createRoutedMiddleware(findRoutedMiddleware: (method: string, pathname: string) => { data: Middleware; }[]): Middleware; export declare function createMethodNotAllowedMatcher(findRoute: (method: string, pathname: string) => unknown, methods: string[]): (method: string, pathname: string) => MatchedRoute | undefined;