mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 04:01:52 +00:00
Add doc comments to koa__cors (#41473)
This commit is contained in:
Vendored
+41
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user