regex-router
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -35,4 +35,10 @@ import { IncomingMessage, ServerResponse } from 'http'; | ||
add(method: string, regExp: RegExp, handler: Handler): void; | ||
/** Copied from http.METHODS, with special match-all ANY */ | ||
static HTTP_METHODS: string[]; | ||
any(regExp: RegExp, handler: Handler): void; | ||
delete(regExp: RegExp, handler: Handler): void; | ||
get(regExp: RegExp, handler: Handler): void; | ||
head(regExp: RegExp, handler: Handler): void; | ||
options(regExp: RegExp, handler: Handler): void; | ||
patch(regExp: RegExp, handler: Handler): void; | ||
post(regExp: RegExp, handler: Handler): void; | ||
put(regExp: RegExp, handler: Handler): void; | ||
} |
43
index.js
@@ -36,8 +36,26 @@ var notFound = function (req, res) { | ||
}; | ||
/** Copied from http.METHODS, with special match-all ANY */ | ||
Router.HTTP_METHODS = ['ANY', | ||
'CHECKOUT', 'CONNECT', 'COPY', 'DELETE', 'GET', 'HEAD', 'LOCK', 'M-SEARCH', | ||
'MERGE', 'MKACTIVITY', 'MKCOL', 'MOVE', 'NOTIFY', 'OPTIONS', 'PATCH', 'POST', | ||
'PROPFIND', 'PROPPATCH', 'PURGE', 'PUT', 'REPORT', 'SEARCH', 'SUBSCRIBE', | ||
'TRACE', 'UNLOCK', 'UNSUBSCRIBE']; | ||
Router.prototype.any = function (regExp, handler) { | ||
this.routes.push({ method: 'ANY', regExp: regExp, handler: handler }); | ||
}; | ||
Router.prototype.delete = function (regExp, handler) { | ||
this.routes.push({ method: 'DELETE', regExp: regExp, handler: handler }); | ||
}; | ||
Router.prototype.get = function (regExp, handler) { | ||
this.routes.push({ method: 'GET', regExp: regExp, handler: handler }); | ||
}; | ||
Router.prototype.head = function (regExp, handler) { | ||
this.routes.push({ method: 'HEAD', regExp: regExp, handler: handler }); | ||
}; | ||
Router.prototype.options = function (regExp, handler) { | ||
this.routes.push({ method: 'OPTIONS', regExp: regExp, handler: handler }); | ||
}; | ||
Router.prototype.patch = function (regExp, handler) { | ||
this.routes.push({ method: 'PATCH', regExp: regExp, handler: handler }); | ||
}; | ||
Router.prototype.post = function (regExp, handler) { | ||
this.routes.push({ method: 'POST', regExp: regExp, handler: handler }); | ||
}; | ||
Router.prototype.put = function (regExp, handler) { | ||
this.routes.push({ method: 'PUT', regExp: regExp, handler: handler }); | ||
}; | ||
return Router; | ||
@@ -48,8 +66,11 @@ })(); | ||
/** | ||
Add router.get(regExp, handler), router.GET(regExp, handler) shortcuts for | ||
all official HTTP method names. | ||
Add shortcuts for other official HTTP method names. | ||
*/ | ||
Router.HTTP_METHODS.forEach(function (method) { | ||
Router.prototype[method] = Router.prototype[method.toLowerCase()] = | ||
function (url, func) { this.add(method, url, func); }; | ||
[ | ||
'CHECKOUT', 'CONNECT', 'COPY', 'LOCK', 'M-SEARCH', 'MERGE', 'MKACTIVITY', | ||
'MKCOL', 'MOVE', 'NOTIFY', 'PROPFIND', 'PROPPATCH', 'PURGE', 'REPORT', | ||
'SEARCH', 'SUBSCRIBE', 'TRACE', 'UNLOCK', 'UNSUBSCRIBE' | ||
].forEach(function (method) { | ||
Router.prototype[method.toLowerCase()] = | ||
function (regExp, handler) { this.routes.push({ method: method, regExp: regExp, handler: handler }); }; | ||
}); |
{ | ||
"name": "regex-router", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Route http(s) requests via regular expressions", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
6159
117
0