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 2.0.0 to 2.0.1

1

lib/resource.js

@@ -30,2 +30,3 @@ /**

for (var action in this.actions) {
if (typeof this.actions[action] !== 'function') continue;
this.routeAction(action, this.actions[action]);

@@ -32,0 +33,0 @@ }

6

package.json

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

"author": "Alex Mingoia <talk@alexmingoia.com>",
"version": "2.0.0",
"version": "2.0.1",
"keywords": [

@@ -19,6 +19,6 @@ "koa",

"lingo": "0.0.5",
"methods": "0.0.1",
"methods": "0.1.0",
"path-to-regexp": "0.0.2",
"debug": "~0.7.4",
"koa-compose": "~2.0.0"
"koa-compose": "~2.1.0"
},

@@ -25,0 +25,0 @@ "devDependencies": {

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

```
npm install --global koa-router
npm install koa-router
```

@@ -86,3 +86,3 @@

function *(next) {
this.user = yield User.findOne(id);
this.user = yield User.findOne(this.params.id);
yield next;

@@ -150,3 +150,25 @@ },

app.resource('users', require('./user'));
app.resource('users', {
// GET /users
index: function *(next) {
},
// GET /users/new
new: function *(next) {
},
// POST /users
create: function *(next) {
},
// GET /users/:id
show: function *(next) {
},
// GET /users/:id/edit
edit: function *(next) {
},
// PUT /users/:id
update: function *(next) {
},
// DELETE /users/:id
destroy: function *(next) {
}
});
```

@@ -153,0 +175,0 @@

@@ -39,2 +39,22 @@ /**

it('should skip non functions', function(done) {
var app = koa();
app.use(Router(app));
var resource = app.resource('forums', {
index: function *() {},
show: function *() {},
config: { port: 8080 }
});
resource.should.be.a('object');
resource.should.have.property('name', 'forums');
resource.should.have.property('id', 'forum');
resource.should.have.property('routes');
resource.routes.should.be.an.instanceOf(Array);
resource.routes.should.have.property(0);
resource.routes.should.have.property(1);
resource.routes[0].should.have.property('path', '/forums');
resource.routes[1].should.have.property('path', '/forums/:forum');
done();
});
it('should nest resources', function(done) {

@@ -41,0 +61,0 @@ var app = koa();

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