express-coroutine
Generator function and Async function to be used as middlewares in express like koa. ( use lei-coroutine )
Installation
npm install express-coroutine --save
Usage
Init express
const express = ;const app = ;
Init router
const express = ;const app = ;const router = ;app; router; // also async functionrouter;
Write your express routes by using generator functions as middlewares.
const express = ; const app = ; app app; // also async functionapp; app;
You can also define multiple generator functions just the express way.
const fn = { return { if reqparamsuser !== 'a' return ; ; };}; const middleware = { ;}; const middleware2 = { await ; ;}; app; app;
More detail demo can be found in test.js
Get coroutine
const coroutine = coroutine;