Add @koa/cors based on kcors (#20310)

This commit is contained in:
Steve Hipwell
2017-10-05 14:46:26 +01:00
committed by Masahiro Wakame
parent 01a5cf5820
commit bb0de78f73
4 changed files with 55 additions and 0 deletions

24
types/koa__cors/index.d.ts vendored Normal file
View File

@@ -0,0 +1,24 @@
// Type definitions for @koa/cors 2.2
// Project: https://github.com/koajs/cors
// Definitions by: Xavier Stouder <https://github.com/Xstoudi>, Izayoi Ko <https://github.com/izayoiko>, Steve Hipwell <https://github.com/stevehipwell>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node"/>
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;
}
}

View File

@@ -0,0 +1,5 @@
import Koa = require('koa');
import cors = require('@koa/cors');
const app = new Koa();
app.use(cors());

View File

@@ -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"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }