Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koa-tree-router

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-tree-router - npm Package Compare versions

Comparing version 0.4.6 to 0.4.7

89

index.d.ts
import * as Koa from "koa";
declare module "koa" {
interface Context {
params: any;
}
}
declare namespace Router {
export interface IMiddleware {
(ctx: Router.IRouterContext, next: () => Promise<any>): any;
}
export interface IRouterOptions {
onMethodNotAllowed?: Router.IMiddleware;
export interface IRouterOptions<StateT = any, CustomT = {}> {
onMethodNotAllowed?: Router.Middleware<StateT, CustomT>;
prefix?: string;
}
export interface IRouterContext extends Koa.Context {
export interface IRouterParamContext<StateT = any, CustomT = {}> {
/**

@@ -22,10 +13,26 @@ * url params

params: { [key: string]: string };
/**
* the router instance
*/
router: Router<StateT, CustomT>;
}
export type RouterContext<
StateT = any,
CustomT = {}
> = Koa.ParameterizedContext<
StateT,
CustomT & IRouterParamContext<StateT, CustomT>
>;
export interface IRouterContext extends RouterContext {}
export type Middleware<StateT = any, CustomT = {}> = Koa.Middleware<
StateT,
CustomT & IRouterParamContext<StateT, CustomT>
>;
}
declare class Router {
declare class Router<StateT = any, CustomT = {}> {
/**
* Create a new router.
*/
constructor(opts?: Router.IRouterOptions);
constructor(opts?: Router.IRouterOptions<StateT, CustomT>);
/**

@@ -37,3 +44,3 @@ * Register a new route.

path: string,
...middleware: Array<Router.IMiddleware>
...middleware: Array<Router.Middleware<StateT, CustomT>>
): this;

@@ -43,45 +50,75 @@ /**

*/
get(path: string, ...middleware: Array<Router.IMiddleware>): this;
get(
path: string,
...middleware: Array<Router.Middleware<StateT, CustomT>>
): this;
/**
* HTTP POST method
*/
post(path: string, ...middleware: Array<Router.IMiddleware>): this;
post(
path: string,
...middleware: Array<Router.Middleware<StateT, CustomT>>
): this;
/**
* HTTP PUT method
*/
put(path: string, ...middleware: Array<Router.IMiddleware>): this;
put(
path: string,
...middleware: Array<Router.Middleware<StateT, CustomT>>
): this;
/**
* HTTP DELETE method
*/
delete(path: string, ...middleware: Array<Router.IMiddleware>): this;
delete(
path: string,
...middleware: Array<Router.Middleware<StateT, CustomT>>
): this;
/**
* HTTP HEAD method
*/
head(path: string, ...middleware: Array<Router.IMiddleware>): this;
head(
path: string,
...middleware: Array<Router.Middleware<StateT, CustomT>>
): this;
/**
* HTTP OPTIONS method
*/
options(path: string, ...middleware: Array<Router.IMiddleware>): this;
options(
path: string,
...middleware: Array<Router.Middleware<StateT, CustomT>>
): this;
/**
* HTTP PATCH method
*/
patch(path: string, ...middleware: Array<Router.IMiddleware>): this;
patch(
path: string,
...middleware: Array<Router.Middleware<StateT, CustomT>>
): this;
/**
* HTTP TRACE method
*/
trace(path: string, ...middleware: Array<Router.IMiddleware>): this;
trace(
path: string,
...middleware: Array<Router.Middleware<StateT, CustomT>>
): this;
/**
* HTTP CONNECT method
*/
connect(path: string, ...middleware: Array<Router.IMiddleware>): this;
connect(
path: string,
...middleware: Array<Router.Middleware<StateT, CustomT>>
): this;
/**
* Register route with all methods.
*/
all(path: string, ...middleware: Array<Router.IMiddleware>): this;
all(
path: string,
...middleware: Array<Router.Middleware<StateT, CustomT>>
): this;
/**
* Returns router middleware.
*/
routes(): Router.IMiddleware;
routes(): Router.Middleware<StateT, CustomT>;
}
export = Router;
{
"name": "koa-tree-router",
"version": "0.4.6",
"version": "0.4.7",
"description": "A high performance koa router",

@@ -42,4 +42,5 @@ "main": "router.js",

"dependencies": {
"@types/koa": "^2.0.48",
"koa-compose": "^4.1.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc