UNPKG

azion

Version:

Azion Packages for Edge Computing.

90 lines (87 loc) 2.61 kB
interface Metadata { geoip_asn: string; geoip_city: string; geoip_city_continent_code: string; geoip_city_country_code: string; geoip_city_country_name: string; geoip_continent_code: string; geoip_country_code: string; geoip_country_name: string; geoip_region: string; geoip_region_name: string; remote_addr: string; remote_port: string; remote_user: string; server_protocol: string; ssl_cipher: string; ssl_protocol: string; [key: string]: string; } /** * Represents the FetchEvent interface. */ interface FetchEvent extends Event { request: Request & { metadata: Metadata; }; waitUntil(promise: Promise<any>): void; respondWith(response: Response | Promise<Response>): void; } /** * Represents the request URL for the SSG or SPA. */ type RequestURL = string; /** * Function that mounts the SSG for a specific request. * @param requestURL - The original URL from the event request. * @returns A promise that resolves to the response from the SSG. */ type mountMPAFunction = (requestURL: RequestURL) => Promise<Response>; /** * Function that mounts the SPA for a specific request. * @param requestURL - The original URL from the event request. * @returns A promise that resolves to the response from the SPA. */ type MountSPAFunction = (requestURL: RequestURL) => Promise<Response>; /** * Function that parses and logs the details of an incoming request. * @param event - The incoming FetchEvent object. * @returns A promise that resolves to the ParsedRequest object. */ type ParseRequestFunction = (event: FetchEvent) => Promise<ParsedRequest>; /** * Function that parses and logs the details of an incoming request. * @param event - The incoming FetchEvent object. * @returns A promise that resolves to the request details object. */ type ParsedRequest = { timestamp: string; method: string; url: { full: string; protocol: string; hostname: string; path: string; query: Record<string, string>; }; headers: Record<string, string>; cookies: Record<string, string>; body: string | null; client: { ip: string; userAgent: string; }; referer: string; origin: string; cacheControl: string; pragma: string; contentType: string; contentLength: string; acceptLanguage: string; acceptEncoding: string; priority: string; host: string; authorization: string; metadata: Metadata; }; export type { MountSPAFunction as M, ParseRequestFunction as P, mountMPAFunction as m };