diff --git a/types/koa__cors/index.d.ts b/types/koa__cors/index.d.ts new file mode 100644 index 0000000000..e0738129e3 --- /dev/null +++ b/types/koa__cors/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for @koa/cors 2.2 +// Project: https://github.com/koajs/cors +// Definitions by: Xavier Stouder , Izayoi Ko , Steve Hipwell +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import * as Koa from "koa"; + +export = cors; + +declare function cors(options?: cors.Options): Koa.Middleware; + +declare namespace cors { + interface Options { + origin?: ((req: Koa.Request) => string) | string; + allowMethods?: string[] | string; + exposeHeaders?: string[] | string; + allowHeaders?: string[] | string; + maxAge?: number | string; + credentials?: boolean; + keepHeadersOnError?: boolean; + } +} diff --git a/types/koa__cors/koa__cors-tests.ts b/types/koa__cors/koa__cors-tests.ts new file mode 100644 index 0000000000..135845f205 --- /dev/null +++ b/types/koa__cors/koa__cors-tests.ts @@ -0,0 +1,5 @@ +import Koa = require('koa'); +import cors = require('@koa/cors'); + +const app = new Koa(); +app.use(cors()); diff --git a/types/koa__cors/tsconfig.json b/types/koa__cors/tsconfig.json new file mode 100644 index 0000000000..1bde80dc70 --- /dev/null +++ b/types/koa__cors/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths":{ + "@koa/cors": ["koa__cors"] + } + }, + "files": [ + "index.d.ts", + "koa__cors-tests.ts" + ] +} diff --git a/types/koa__cors/tslint.json b/types/koa__cors/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/koa__cors/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }