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

koa-mount

Package Overview
Dependencies
Maintainers
8
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-mount - npm Package Compare versions

Comparing version 1.3.0 to 2.0.0

History.md

31

index.js

@@ -48,22 +48,23 @@

return function *(upstream){
var prev = this.path;
return function (ctx, upstream){
var prev = ctx.path;
var newPath = match(prev);
debug('mount %s %s -> %s', prefix, name, newPath);
if (!newPath) return yield* upstream;
if (!newPath) return upstream();
this.mountPath = prefix;
this.path = newPath;
debug('enter %s -> %s', prev, this.path);
ctx.mountPath = prefix;
ctx.path = newPath;
debug('enter %s -> %s', prev, ctx.path);
yield* downstream.call(this, function *(){
this.path = prev;
yield* upstream;
this.path = newPath;
}.call(this));
return Promise.resolve(downstream(ctx, () => {
ctx.path = prev;
return upstream().then(() => {
ctx.path = newPath;
});
})).then(() => {
debug('leave %s -> %s', prev, ctx.path);
ctx.path = prev;
});
};
debug('leave %s -> %s', prev, this.path);
this.path = prev;
}
/**

@@ -70,0 +71,0 @@ * Check if `prefix` satisfies a `path`.

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

"repository": "koajs/mount",
"version": "1.3.0",
"version": "2.0.0",
"keywords": [

@@ -17,15 +17,21 @@ "koa",

"devDependencies": {
"koa": "latest",
"should": "^3.0.0",
"mocha": "^1.12.1",
"supertest": "~0.10.0"
"babel-cli": "6",
"babel-core": "6",
"babel-plugin-transform-async-to-generator": "6",
"istanbul": "0",
"koa": "^2.0.0-alpha.3",
"mocha": "2",
"should": "8",
"supertest": "1"
},
"license": "MIT",
"dependencies": {
"koa-compose": "^2.2.0",
"debug": "*"
"debug": "*",
"koa-compose": "^3.0.0"
},
"scripts": {
"test": "make test"
"test": "NODE_ENV=test mocha --require babel-core/register --reporter spec",
"test-cov": "NODE_ENV=test node --harmony ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --require babel-core/register",
"test-travis": "NODE_ENV=test node --harmony ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- --require babel-core/register"
}
}
# koa-mount
Mount other Koa applications as middleware. The `path` passed to `mount()` is stripped
from the URL temporarily until the stack unwinds. This is useful for creating entire
from the URL temporarily until the stack unwinds. This is useful for creating entire
apps or middleware that will function correctly regardless of which path segment(s)

@@ -27,11 +27,11 @@ they should operate on.

var mount = require('koa-mount');
var koa = require('koa');
var Koa = require('koa');
// hello
var a = koa();
var a = new Koa();
a.use(function *(next){
yield next;
this.body = 'Hello';
a.use(async function (ctx, next){
await next();
ctx.body = 'Hello';
});

@@ -41,7 +41,7 @@

var b = koa();
var b = new Koa();
b.use(function *(next){
yield next;
this.body = 'World';
b.use(async function (ctx, next){
await next();
ctx.body = 'World';
});

@@ -51,3 +51,3 @@

var app = koa();
var app = new Koa();

@@ -81,15 +81,15 @@ app.use(mount('/hello', a));

var mount = require('koa-mount');
var koa = require('koa');
var Koa = require('koa');
function *hello(next){
yield next;
this.body = 'Hello';
async function hello(ctx, next){
await next();
ctx.body = 'Hello';
}
function *world(next){
yield next;
this.body = 'World';
async function world(ctx, next){
await next();
ctx.body = 'World';
}
var app = koa();
var app = new Koa();

@@ -96,0 +96,0 @@ app.use(mount('/hello', hello));

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