mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
NEW: Type definitions for koa-dec-router (#36696)
* NEW: Type definitions for koa-dec-router * FIX: Type definitions for koa-dec-router
This commit is contained in:
parent
74a49e887e
commit
3f28071fcb
33
types/koa-dec-router/index.d.ts
vendored
Normal file
33
types/koa-dec-router/index.d.ts
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
// Type definitions for koa-dec-router 0.0
|
||||
// Project: https://github.com/zaaack/koa-dec-router
|
||||
// Definitions by: Yerden Kembayev <https://github.com/aarystan>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.7
|
||||
|
||||
export const CTRL_PATH: symbol;
|
||||
|
||||
export const MIDDLEWARES: symbol;
|
||||
|
||||
export const OPTIONS: symbol;
|
||||
|
||||
export const ROUTES: symbol;
|
||||
|
||||
export function controller(path: any, opts?: any, ...args: any[]): any;
|
||||
|
||||
export function route(method: string, path: any, opts?: any, ...args: any[]): any;
|
||||
|
||||
export function get(...args: any[]): any;
|
||||
|
||||
export function head(...args: any[]): any;
|
||||
|
||||
export function patch(...args: any[]): any;
|
||||
|
||||
export function post(...args: any[]): any;
|
||||
|
||||
export function put(...args: any[]): any;
|
||||
|
||||
export function del(...args: any[]): any;
|
||||
|
||||
export function all(...args: any[]): any;
|
||||
|
||||
export default function(opts: any): any;
|
||||
40
types/koa-dec-router/koa-dec-router-tests.ts
Normal file
40
types/koa-dec-router/koa-dec-router-tests.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import DecRouter, { controller, get, post } from 'koa-dec-router';
|
||||
|
||||
class Ctx {
|
||||
body: any;
|
||||
params: any;
|
||||
}
|
||||
|
||||
const bazHandler = (ctx: Ctx, next: () => void) => {
|
||||
next();
|
||||
};
|
||||
|
||||
@controller('/foo')
|
||||
export class FooController {
|
||||
@get('/baz')
|
||||
async fooBaz(ctx: Ctx) {
|
||||
ctx.body = '/foo/baz';
|
||||
}
|
||||
|
||||
@get()
|
||||
async foo(ctx: Ctx) {
|
||||
ctx.body = '/foo';
|
||||
}
|
||||
|
||||
@get('/:code', { priority: -1 })
|
||||
async fooCode(ctx: Ctx) {
|
||||
ctx.body = '/foo/' + ctx.params.code;
|
||||
}
|
||||
}
|
||||
|
||||
@controller('/baz', bazHandler)
|
||||
export class BazController {
|
||||
@get('/foo')
|
||||
async fooBaz(ctx: Ctx) {
|
||||
ctx.body = '/foo/baz';
|
||||
}
|
||||
}
|
||||
|
||||
const decRouter = DecRouter({
|
||||
controllersDir: './'
|
||||
});
|
||||
25
types/koa-dec-router/tsconfig.json
Normal file
25
types/koa-dec-router/tsconfig.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"experimentalDecorators": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"koa-dec-router-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/koa-dec-router/tslint.json
Normal file
3
types/koa-dec-router/tslint.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user