koa-mount-pattern
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

koa-mount-pattern

As you may know, there's a famous middleware called koa-mount which is used to mount a middleware to a specific path. But what if you want to mount a middleware to a path pattern? For example, you want to mount a middleware to all paths that start with /api/(v1|v2|v3)? This is where koa-mount-pattern comes in.

Installation

npm install koa-mount-pattern

Usage

const Koa = require('koa');
const { mountPattern } = require('koa-mount-pattern');

const app = new Koa();
app.use(mountPattern('/api/:version', async (ctx, next) => {
  // do something
  await next();
}));

Readme

Keywords

none

Package Sidebar

Install

npm i koa-mount-pattern

Weekly Downloads

1

Version

0.1.1

License

none

Unpacked Size

13.2 kB

Total Files

15

Last publish

Collaborators

  • joyqi