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

Mounting middleware for koa

  • 4.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
141K
decreased by-2.92%
Maintainers
8
Weekly downloads
 
Created

What is koa-mount?

The `koa-mount` package is a middleware for the Koa framework that allows you to mount other Koa applications or middleware at specific paths. This is useful for structuring your application into smaller, more manageable pieces or for integrating third-party applications.

What are koa-mount's main functionalities?

Mounting a Koa application at a specific path

This feature allows you to mount a sub-application at a specific path. In this example, requests to `/sub` will be handled by `subApp`.

const Koa = require('koa');
const mount = require('koa-mount');

const app = new Koa();
const subApp = new Koa();

subApp.use(async (ctx) => {
  ctx.body = 'Hello from subApp!';
});

app.use(mount('/sub', subApp));

app.listen(3000, () => {
  console.log('Server running on http://localhost:3000');
});

Mounting middleware at a specific path

This feature allows you to mount specific middleware at a given path. In this example, requests to `/middleware` will be handled by the `middleware` function.

const Koa = require('koa');
const mount = require('koa-mount');

const app = new Koa();

const middleware = async (ctx, next) => {
  ctx.body = 'Hello from middleware!';
  await next();
};

app.use(mount('/middleware', middleware));

app.listen(3000, () => {
  console.log('Server running on http://localhost:3000');
});

Other packages similar to koa-mount

Keywords

FAQs

Package last updated on 26 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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