{"name":"koa-mount","version":"4.2.0","keywords":["koa","middleware","mount","mounting"],"license":"MIT","_id":"koa-mount@4.2.0","maintainers":[{"name":"coderhaoxin","email":"haoxinst@gmail.com"},{"name":"aaron","email":"aaron.heckmann+github@gmail.com"},{"name":"juliangruber","email":"julian@juliangruber.com"},{"name":"eivifj","email":"eivind.fjeldstad@gmail.com"},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"tjholowaychuk","email":"tj@vision-media.ca"},{"name":"jongleberry","email":"jonathanrichardong@gmail.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"}],"homepage":"https://github.com/koajs/mount#readme","bugs":{"url":"https://github.com/koajs/mount/issues"},"dist":{"shasum":"66f4436cac76af3075ac432d503299f7678d5914","tarball":"http://registry-npm.ywwl.com/koa-mount/download/koa-mount-4.2.0.tgz","fileCount":3,"integrity":"sha512-2iHQc7vbA9qLeVq5gKAYh3m5DOMMlMfIKjW/REPAS18Mf63daCJHHVXY9nbu7ivrnYn5PiPC4CE523Tf5qvjeQ==","signatures":[{"sig":"MEQCICrA3IwHeHmQ0sjOf6vdzHHdNGVd3LFg/Nemt4beYtFrAiBZwyCR9r84HuAnep7bIxwFV303aVDAWmg/peHU2nYkAQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5496,"size":2223,"noattachment":false,"key":"/koa-mount/-/koa-mount-4.2.0.tgz"},"engines":{"node":">= 7.6.0"},"gitHead":"3f14cbb8b0d0812ef7299434dffe6f784e8933fe","scripts":{"lint":"eslint --fix .","test":"NODE_ENV=test mocha --reporter spec","test-cov":"NODE_ENV=test istanbul cover ./node_modules/.bin/_mocha","test-travis":"NODE_ENV=test istanbul cover ./node_modules/.bin/_mocha --report lcovonly"},"_npmUser":{"name":"jongleberry","email":"jonathanrichardong@gmail.com"},"repository":{"url":"git+https://github.com/koajs/mount.git","type":"git"},"_npmVersion":"10.9.2","description":"Mounting middleware for koa","directories":{},"_nodeVersion":"22.14.0","dependencies":{"debug":"^4.0.1","koa-compose":"^4.1.0"},"_hasShrinkwrap":false,"devDependencies":{"koa":"^2.0.1","mocha":"^9.1.1","eslint":"^7.32.0","should":"^11.2.0","istanbul":"^0.4.5","supertest":"^6.1.6","koa-static":"^5.0.0","eslint-plugin-promise":"^3.5.0","eslint-config-standard":"^7.1.0","eslint-plugin-standard":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/koa-mount_4.2.0_1745740903045_0.45926383926516223","host":"s3://npm-registry-packages-npm-production"},"readme":"# koa-mount\n\n  Mount other Koa applications as middleware. The `path` passed to `mount()` is stripped\n  from the URL temporarily until the stack unwinds. This is useful for creating entire\n  apps or middleware that will function correctly regardless of which path segment(s)\n  they should operate on.\n\n## Installation\n\n```js\n$ npm install koa-mount\n```\n\n## Examples\n\n  View the [./examples](examples) directory for working examples.\n\n### Mounting Applications\n\n  Entire applications mounted at specific paths. For example you could mount\n  a blog application at \"/blog\", with a router that matches paths such as\n  \"GET /\", \"GET /posts\", and will behave properly for \"GET /blog/posts\" etc\n  when mounted.\n\n```js\nconst mount = require('koa-mount');\nconst Koa = require('koa');\n\n// hello\n\nconst a = new Koa();\n\na.use(async function (ctx, next){\n  await next();\n  ctx.body = 'Hello';\n});\n\n// world\n\nconst b = new Koa();\n\nb.use(async function (ctx, next){\n  await next();\n  ctx.body = 'World';\n});\n\n// app\n\nconst app = new Koa();\n\napp.use(mount('/hello', a));\napp.use(mount('/world', b));\n\napp.listen(3000);\nconsole.log('listening on port 3000');\n```\n\n  Try the following requests:\n\n```\n$ GET /\nNot Found\n\n$ GET /hello\nHello\n\n$ GET /world\nWorld\n```\n\n### Mounting Middleware\n\n  Mount middleware at specific paths, allowing them to operate independently\n  of the prefix, as they're not aware of it.\n\n```js\nconst mount = require('koa-mount');\nconst Koa = require('koa');\n\nasync function hello(ctx, next){\n  await next();\n  ctx.body = 'Hello';\n}\n\nasync function world(ctx, next){\n  await next();\n  ctx.body = 'World';\n}\n\nconst app = new Koa();\n\napp.use(mount('/hello', hello));\napp.use(mount('/world', world));\n\napp.listen(3000);\nconsole.log('listening on port 3000');\n```\n\n### Optional Paths\n\n  The path argument is optional, defaulting to \"/\":\n\n```js\napp.use(mount(a));\napp.use(mount(b));\n```\n\n## Debugging\n\n  Use the __DEBUG__ environement variable to whitelist\n  koa-mount debug output:\n\n```\n$ DEBUG=koa-mount node myapp.js &\n$ GET /foo/bar/baz\n\n  koa-mount enter /foo/bar/baz -> /bar/baz +2s\n  koa-mount enter /bar/baz -> /baz +0ms\n  koa-mount enter /baz -> / +0ms\n  koa-mount leave /baz -> / +1ms\n  koa-mount leave /bar/baz -> /baz +0ms\n  koa-mount leave /foo/bar/baz -> /bar/baz +0ms\n```\n\n## License\n\n  MIT\n","publish_time":1745740903197,"_cnpm_publish_time":1745740903197,"dist-tags":{"latest":"4.2.0","latest-1":"1.3.1","next":"2.0.0"}}