Socket
Socket
Sign inDemoInstall

koa-router

Package Overview
Dependencies
Maintainers
1
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-router - npm Package Compare versions

Comparing version 1.5.3 to 1.5.4

26

lib/router.js

@@ -60,19 +60,15 @@ /**

var route = router.match(this.req.method, parse(this.req.url).path);
if (!route) return yield next;
// Dispatch route callbacks
if (route) {
var args;
this.app.context({ route: route, params: route.params });
for (var len = route.callbacks.length, i=0; i<len; i++) {
args = yield route.callbacks[i].apply(
this,
// Route callbacks may return an array of arguments to be
// applied to the next callback, otherwise default to the captured
// route parameters.
(args ? args : route.paramsArray).concat([next])
);
}
var args;
this.app.context({ route: route, params: route.params });
for (var len = route.callbacks.length, i=0; i<len; i++) {
args = yield route.callbacks[i].apply(
this,
// Route callbacks may return an array of arguments to be
// applied to the next callback, otherwise default to the captured
// route parameters.
(args ? args : route.paramsArray).concat([next])
);
}
else {
yield next;
}
};

@@ -79,0 +75,0 @@ };

@@ -9,3 +9,3 @@ {

"author": "Alex Mingoia <talk@alexmingoia.com>",
"version": "1.5.3",
"version": "1.5.4",
"keywords": ["koa", "middleware", "router", "route"],

@@ -12,0 +12,0 @@ "dependencies": {

@@ -55,7 +55,7 @@ # Router middleware for [koa](https://github.com/koajs/koa)

`app.verb()` methods are provided to create routes, where **verb** is one of
the HTTP verbs, such as `app.get()` or `app.post()`.
Match URL patterns to callback functions or controller actions using `app.verb()`,
where **verb** is one of the HTTP verbs such as `app.get()` or `app.post()`.
app.get('/', function *(next) {
// ...
this.body = 'Hello World!';
});

@@ -66,3 +66,3 @@

Multiple callbacks may be given, and each one will be called sequentially.
Multiple callbacks may be given, and each one will be called sequentially:

@@ -83,3 +83,3 @@ app.get(

##### Named parameters
#### Named parameters

@@ -94,3 +94,3 @@ Named route parameters are captured and passed as arguments to the route callback.

##### Regular expressions
#### Regular expressions

@@ -105,3 +105,3 @@ Control route matching exactly by specifying a regular expression instead of

##### Multiple methods
#### Multiple methods

@@ -120,15 +120,2 @@ You can map routes to multiple HTTP methods using `app.map()`:

### app.redirect(path, destination, [code])
Redirect `path` to `destination` URL with optional 30x status `code`.
app.redirect('/login', 'sign-in');
This is equivalent to:
app.all('/login', function *() {
this.redirect('/sign-in');
this.status = 301;
});
### app.resource(path, actions)

@@ -147,3 +134,3 @@

##### Action mapping
#### Action mapping

@@ -160,3 +147,3 @@ Actions are then mapped accordingly:

##### Top-level resource
#### Top-level resource

@@ -177,3 +164,3 @@ Omit the resource name to specify a top-level resource:

##### Auto-loading
#### Auto-loading

@@ -199,3 +186,3 @@ Automatically load requested resources by specifying the `load` action

##### Nesting
#### Nesting

@@ -209,2 +196,15 @@ Resources can be nested using `resource.add()`:

### app.redirect(path, destination, [code])
Redirect `path` to `destination` URL with optional 30x status `code`.
app.redirect('/login', 'sign-in');
This is equivalent to:
app.all('/login', function *() {
this.redirect('/sign-in');
this.status = 301;
});
## Tests

@@ -211,0 +211,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