nomi-mwloader

nomi框架 中间件loader

Usage no npm install needed!

<script type="module">
  import nomiMwloader from 'https://cdn.skypack.dev/nomi-mwloader';
</script>

README

nomi-mwloader

the middleware-loader tool for loading the nomi middlewares!

Installation

$ npm install nomi-mwloader --save

Node.js >= 8.0.0 required.

API

  • use

Usage


const MiddlewareLoader = require('nomi-mwloader');
const ctx = new Koa().ctx;
const mwLoader = new MiddlewareLoader({
      "global": [
        {
          "name": "GMiddleware", 
          "enable": true
        }],
      "local": [ 
        {
          "name": 'LMiddleware',
          "enable": true
        }
      ] 
    }, 'd:app');

mwLoader.use(ctx, 'LMiddleware');
mwLoader.use(ctx, ['LMiddleware']);
mwLoader.use(ctx, 'LMiddleware', () => {
  // to do something
});