Add doc comments to koa__cors (#41473)

This commit is contained in:
sripberger
2020-01-15 03:26:42 -05:00
committed by Eli Barzilay
parent 98169480bc
commit 58e9477251
+41
View File
@@ -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>) | 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;
}
}