UNPKG

@h4ad/serverless-adapter

Version:

Run REST APIs and other web applications using your existing Node.js application framework (NestJS, Express, Koa, Hapi, Fastify and many others), on top of AWS, Azure, Digital Ocean and many other clouds.

87 lines (84 loc) 2.94 kB
import { HttpRequest, Context, HttpResponseSimple, Cookie } from '@azure/functions'; import { B as BothValueHeaders } from '../../headers-DjfGHDmI.cjs'; import { A as AdapterContract, a as AdapterRequest, G as GetResponseAdapterProps, O as OnErrorProps } from '../../adapter.contract-Cp2Jsh5V.cjs'; import 'http'; import 'node:http'; import '../../logger-F8qccesk.cjs'; /** * The options to customize the {@link HttpTriggerV4Adapter} * * @breadcrumb Adapters / Azure / HttpTriggerV4Adapter * @public */ interface HttpTriggerV4AdapterOptions { /** * Strip base path for custom domains * * @defaultValue '' */ stripBasePath?: string; } /** * The adapter to handle requests from Http Trigger on Azure Function V4. * * @example * ```typescript * const stripBasePath = '/any/custom/base/path'; // default '' * const adapter = new HttpTriggerV4Adapter({ stripBasePath }); * ``` * * @see {@link https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-node | Reference} * * @breadcrumb Adapters / Azure / HttpTriggerV4Adapter * @public */ declare class HttpTriggerV4Adapter implements AdapterContract<HttpRequest, Context, HttpResponseSimple> { protected readonly options?: HttpTriggerV4AdapterOptions | undefined; /** * Default constructor * * @param options - The options to customize the {@link HttpTriggerV4Adapter} */ constructor(options?: HttpTriggerV4AdapterOptions | undefined); /** * {@inheritDoc} */ getAdapterName(): string; /** * {@inheritDoc} */ canHandle(event: unknown, context: unknown): boolean; /** * {@inheritDoc} */ getRequest(event: HttpRequest): AdapterRequest; /** * {@inheritDoc} */ getResponse({ body, statusCode, headers: originalHeaders, }: GetResponseAdapterProps<HttpRequest>): HttpResponseSimple; /** * {@inheritDoc} */ onErrorWhileForwarding({ error, respondWithErrors, event, delegatedResolver, log, }: OnErrorProps<HttpRequest, HttpResponseSimple>): void; /** * Get path from event with query strings * * @param event - The event sent by serverless */ protected getPathFromEvent(event: HttpRequest): string; /** * Get the Azure Cookie list parsed from set-cookie header. * * @param headers - The headers object */ protected getAzureCookiesFromHeaders(headers: BothValueHeaders): Cookie[]; /** * Parse the string cookie to the Azure Cookie Object. * This code was written by {@link https://github.com/zachabney | @zachabney} * on {@link https://github.com/zachabney/azure-aws-serverless-express/blob/241d2d5c4d5906e4817662cad6426ec2cbbf9ca7/src/index.js#L4-L49 | this library}. * * @param cookie - The cookie */ protected parseCookie(cookie: string): Cookie; } export { HttpTriggerV4Adapter, type HttpTriggerV4AdapterOptions };