JSPM

morph-middleware

1.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q16935F
  • License MIT

Middleware implementation

Package Exports

  • morph-middleware

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (morph-middleware) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Morph: Middleware

Middleware implementation module. Work in progress

Installing

You can use the command npm i morph-middleware.

Getting Started

const Middleware = require('morph-middleware');

let test = new Middleware();

test.use('First', async function() {
  console.dir(this);
  this.pass('wow', 'lol');
});

test.use('Second', async function(object, string, array) { // Arguments from Middleware#go
  console.dir(arguments);
  return { second: true };
});

test.use('Third', async function() {
  this.break('this is a test');
});

test.use('Four', async () => console.log('This will never be called'));

test.pre('BEFORE EVERYTHING!', async () => {
  console.log('This will be called before everything');
  return { is: 'this', working: '?', of: 'course' };
});

test.go({ this: 'is' }, 'a', ['test']).then(d => console.log('Middleware done: ' + JSON.stringify(d)));

You can either return an object or use this.pass to pass data. You can access it with this.data.

If you use arrow functions you lose this and its functions break, and pass.

Coming soon

Priority system