From bb0de78f73d2a241a7b8dc5735edba3492a775d7 Mon Sep 17 00:00:00 2001 From: Steve Hipwell Date: Thu, 5 Oct 2017 14:46:26 +0100 Subject: [PATCH] Add @koa/cors based on kcors (#20310) --- types/koa__cors/index.d.ts | 24 ++++++++++++++++++++++++ types/koa__cors/koa__cors-tests.ts | 5 +++++ types/koa__cors/tsconfig.json | 25 +++++++++++++++++++++++++ types/koa__cors/tslint.json | 1 + 4 files changed, 55 insertions(+) create mode 100644 types/koa__cors/index.d.ts create mode 100644 types/koa__cors/koa__cors-tests.ts create mode 100644 types/koa__cors/tsconfig.json create mode 100644 types/koa__cors/tslint.json 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" }