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

koa-route

Package Overview
Dependencies
Maintainers
10
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-route - npm Package Compare versions

Comparing version 3.2.0 to 4.0.0

11

index.js

@@ -8,3 +8,3 @@

const pathToRegexp = require('path-to-regexp');
const { pathToRegexp } = require('path-to-regexp');
const debug = require('debug')('koa-route');

@@ -24,6 +24,11 @@ const methods = require('methods');

return function(path, fn, opts){
const re = pathToRegexp(path, opts);
const keys = [];
const re = pathToRegexp(path, keys, opts);
debug('%s %s -> %s', method || 'ALL', path, re);
const createRoute = function(routeFunc){
if (typeof fn !== 'function') {
throw new TypeError('Route handler must be a function');
}
const createRoute = function(routeFunc) {
return function (ctx, next){

@@ -30,0 +35,0 @@ // method

@@ -5,3 +5,3 @@ {

"repository": "koajs/route",
"version": "3.2.0",
"version": "4.0.0",
"keywords": [

@@ -17,8 +17,8 @@ "koa",

],
"main": "index.js",
"devDependencies": {
"istanbul-harmony": "0",
"koa": "^2.0.0-alpha.3",
"mocha": "^2.2.5",
"koa": "^2.15.0",
"mocha": "^10.3.0",
"should": "*",
"supertest": "0"
"supertest": "^6.3.4"
},

@@ -29,9 +29,7 @@ "license": "MIT",

"methods": "~1.1.0",
"path-to-regexp": "^1.2.0"
"path-to-regexp": "^6.2.1"
},
"scripts": {
"test": "NODE_ENV=test mocha --harmony --require should --reporter spec",
"test-cov": "NODE_ENV=test node --harmony ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --require should",
"test-travis": "NODE_ENV=test node --harmony ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- --require should"
"test": "NODE_ENV=test mocha --harmony --require should --reporter spec --exit"
}
}

@@ -6,3 +6,3 @@ # koa-route

```js
var _ = require('koa-route');
const _ = require('koa-route');
app.use(_.get('/pets', pets.list));

@@ -12,3 +12,3 @@ app.use(_.get('/pets/:name', pets.show));

If you need a full-featured solution check out [koa-router](https://github.com/alexmingoia/koa-router),
If you need a full-featured solution check out [koa-router](https://github.com/koajs/router),
a Koa clone of express-resource.

@@ -19,3 +19,3 @@

```js
$ npm install koa-route@next
$ npm install koa-route
```

@@ -28,7 +28,7 @@

```js
var _ = require('koa-route');
var Koa = require('koa');
var app = new Koa();
const _ = require('koa-route');
const Koa = require('koa');
const app = new Koa();
var db = {
const db = {
tobi: { name: 'tobi', species: 'ferret' },

@@ -39,5 +39,5 @@ loki: { name: 'loki', species: 'ferret' },

var pets = {
const pets = {
list: (ctx) => {
var names = Object.keys(db);
const names = Object.keys(db);
ctx.body = 'pets: ' + names.join(', ');

@@ -47,3 +47,3 @@ },

show: (ctx, name) => {
var pet = db[name];
const pet = db[name];
if (!pet) return ctx.throw('cannot find that pet', 404);

@@ -57,4 +57,6 @@ ctx.body = pet.name + ' is a ' + pet.species;

app.listen(3000);
console.log('listening on port 3000');
app.listen(3000, (err) => {
if (err) console.error(err.stack);
else console.log('listening on port 3000');
});
```

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