From 58e9477251dfcb64fa64378a6c15dc7da715c905 Mon Sep 17 00:00:00 2001 From: sripberger Date: Wed, 15 Jan 2020 03:26:42 -0500 Subject: [PATCH] Add doc comments to koa__cors (#41473) --- types/koa__cors/index.d.ts | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/types/koa__cors/index.d.ts b/types/koa__cors/index.d.ts index 8b44fb8a43..6b2e5342e1 100644 --- a/types/koa__cors/index.d.ts +++ b/types/koa__cors/index.d.ts @@ -11,16 +11,57 @@ import * as Koa from 'koa'; export = cors; +/** + * CORS middleware factory. + * @param options - Configuration options. + * @returns cors middleware + */ declare function cors(options?: cors.Options): Koa.Middleware; declare namespace cors { + /** + * Middleware configration options. + */ interface Options { + /** + * `Access-Control-Allow-Origin`, default is request Origin header. + * + * @remarks + * If a function is provided, it will be called for each request with + * the koa context object. It may return a string or a promise that + * will resolve with a string. + */ origin?: ((ctx: Koa.Context) => string) | ((ctx: Koa.Context) => PromiseLike) | string; + + /** + * `Access-Control-Allow-Methods`, default is + * 'GET,HEAD,PUT,POST,DELETE,PATCH' + */ allowMethods?: string[] | string; + + /** + * `Access-Control-Expose-Headers` + */ exposeHeaders?: string[] | string; + + /** + * `Access-Control-Allow-Headers` + */ allowHeaders?: string[] | string; + + /** + * `Access-Control-Max-Age` in seconds + */ maxAge?: number | string; + + /** + * `Access-Control-Allow-Credentials` + */ credentials?: boolean; + + /** + * Add set headers to `err.header` if an error is thrown + */ keepHeadersOnError?: boolean; } }