appolo-agent
Advanced tools
Comparing version 6.0.27 to 6.0.28
@@ -138,2 +138,11 @@ "use strict"; | ||
} | ||
all(path, ...handler) { | ||
this.add(appolo_route_1.Methods.GET, path, handler) | ||
.add(appolo_route_1.Methods.PATCH, path, handler) | ||
.add(appolo_route_1.Methods.POST, path, handler) | ||
.add(appolo_route_1.Methods.PUT, path, handler) | ||
.add(appolo_route_1.Methods.DELETE, path, handler) | ||
.add(appolo_route_1.Methods.HEAD, path, handler); | ||
return this; | ||
} | ||
add(method, path, handlers, route, hooks) { | ||
@@ -170,3 +179,9 @@ handlers = _(handlers).map(handler => _.isArray(handler) ? handler : [handler]).flatten().value(); | ||
} | ||
use(...fn) { | ||
use(path, ...fn) { | ||
if (typeof path === "string") { | ||
return this.all(path, ...fn); | ||
} | ||
else { | ||
fn.unshift(path); | ||
} | ||
let result = _.partition(fn, handler => handler.length <= 3); | ||
@@ -173,0 +188,0 @@ if (result[0].length) { |
@@ -218,2 +218,13 @@ import {IOptions} from "./IOptions"; | ||
public all(path: string, ...handler: MiddlewareHandlerParams[]): this { | ||
this.add(Methods.GET, path, handler) | ||
.add(Methods.PATCH, path, handler) | ||
.add(Methods.POST, path, handler) | ||
.add(Methods.PUT, path, handler) | ||
.add(Methods.DELETE, path, handler) | ||
.add(Methods.HEAD, path, handler) | ||
return this; | ||
} | ||
public add(method: keyof typeof Methods, path: string, handlers: MiddlewareHandlerParams[], route?: any, hooks?: IHooks): this { | ||
@@ -263,4 +274,10 @@ | ||
public use(...fn: MiddlewareHandlerParams[]): this { | ||
public use(path: string | MiddlewareHandlerParams, ...fn: MiddlewareHandlerParams[]): this { | ||
if (typeof path === "string") { | ||
return this.all(path, ...fn) | ||
} else { | ||
fn.unshift(path) | ||
} | ||
let result = _.partition(fn, handler => handler.length <= 3); | ||
@@ -267,0 +284,0 @@ |
@@ -27,3 +27,3 @@ { | ||
"main": "./index.js", | ||
"version": "6.0.27", | ||
"version": "6.0.28", | ||
"license": "MIT", | ||
@@ -72,4 +72,4 @@ "repository": { | ||
"mocha": "^5.2.0", | ||
"nunjucks": "^3.1.4", | ||
"nyc": "^13.3.0", | ||
"nunjucks": "^3.2.0", | ||
"nyc": "^14.1.1", | ||
"sinon": "^7.2.4", | ||
@@ -76,0 +76,0 @@ "sinon-chai": "^3.3.0", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102475
1728