sveltekit-service-manager - v1.1.0
    Preparing search index...

    Interface ServiceRequestEvent<Params, RouteId>

    Enhanced RequestEvent passed into service handlers.

    Adds route.base, route.service and a rewritten url that points at the service-relative path.

    interface ServiceRequestEvent<
        Params extends
            Record<string, string | string[] | undefined> = Record<string, string>,
        RouteId extends string
        | null = string | null,
    > {
        cookies: Cookies;
        fetch: {
            (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
            (input: string | Request | URL, init?: RequestInit): Promise<Response>;
        };
        getClientAddress: () => string;
        isDataRequest: boolean;
        isRemoteRequest: boolean;
        isSubRequest: boolean;
        locals: Locals;
        params: Params;
        platform: Readonly<Platform> | undefined;
        request: Request;
        route: {
            base: string;
            baseURL: URL;
            id: RouteId;
            originalURL: URL;
            service: string;
            serviceURL: URL;
        };
        setHeaders: (headers: Record<string, string>) => void;
        tracing: { current: any; enabled: boolean; root: any };
        url: URL;
    }

    Type Parameters

    • Params extends Record<string, string | string[] | undefined> = Record<string, string>
    • RouteId extends string | null = string | null

    Hierarchy

    • Omit<RequestEvent<any, RouteId>, "params">
      • ServiceRequestEvent
    Index

    Properties

    cookies: Cookies

    Get or set cookies related to the current request

    fetch: {
        (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
        (input: string | Request | URL, init?: RequestInit): Promise<Response>;
    }

    fetch is equivalent to the native fetch web API, with a few additional features:

    • It can be used to make credentialed requests on the server, as it inherits the cookie and authorization headers for the page request.
    • It can make relative requests on the server (ordinarily, fetch requires a URL with an origin when used in a server context).
    • Internal requests (e.g. for +server.js routes) go directly to the handler function when running on the server, without the overhead of an HTTP call.
    • During server-side rendering, the response will be captured and inlined into the rendered HTML by hooking into the text and json methods of the Response object. Note that headers will not be serialized, unless explicitly included via filterSerializedResponseHeaders
    • During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request.

    You can learn more about making credentialed requests with cookies here.

    Type Declaration

      • (input: URL | RequestInfo, init?: RequestInit): Promise<Response>
      • Parameters

        • input: URL | RequestInfo
        • Optionalinit: RequestInit

        Returns Promise<Response>

      • (input: string | Request | URL, init?: RequestInit): Promise<Response>
      • Parameters

        • input: string | Request | URL
        • Optionalinit: RequestInit

        Returns Promise<Response>

    getClientAddress: () => string

    The client's IP address, set by the adapter.

    isDataRequest: boolean

    true if the request comes from the client asking for +page/layout.server.js data. The url property will be stripped of the internal information related to the data request in this case. Use this property instead if the distinction is important to you.

    isRemoteRequest: boolean

    true if the request comes from the client via a remote function. The url property will be stripped of the internal information related to the data request in this case. Use this property instead if the distinction is important to you.

    isSubRequest: boolean

    true for +server.js calls coming from SvelteKit without the overhead of actually making an HTTP request. This happens when you make same-origin fetch requests on the server.

    locals: Locals

    Contains custom data that was added to the request within the server handle hook.

    params: Params
    platform: Readonly<Platform> | undefined

    Additional data made available through the adapter.

    request: Request

    The original request object.

    route: {
        base: string;
        baseURL: URL;
        id: RouteId;
        originalURL: URL;
        service: string;
        serviceURL: URL;
    }

    Info about the current route.

    setHeaders: (headers: Record<string, string>) => void

    If you need to set headers for the response, you can do so using the this method. This is useful if you want the page to be cached, for example:

    ```js
    /// file: src/routes/blog/+page.js
    export async function load({ fetch, setHeaders }) {
    	const url = `https://cms.example.com/articles.json`;
    	const response = await fetch(url);
    
    	setHeaders({
    		age: response.headers.get('age'),
    		'cache-control': response.headers.get('cache-control')
    	});
    
    	return response.json();
    }
    ```
    

    Setting the same header multiple times (even in separate load functions) is an error — you can only set a given header once.

    You cannot add a set-cookie header with setHeaders — use the cookies API instead.

    tracing: { current: any; enabled: boolean; root: any }

    Access to spans for tracing. If tracing is not enabled, these spans will do nothing.

    Type Declaration

    • current: any

      The span associated with the current handle hook, load function, or form action.

    • enabled: boolean

      Whether tracing is enabled.

    • root: any

      The root span for the request. This span is named sveltekit.handle.root.

    2.31.0

    url: URL

    The requested URL.