1.0.0 • Published 3 years ago

crepecake-common v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

crepecake-common

Commonly-used middlewares for crepecake.

Default middlewares

  1. compress: https://github.com/koajs/compress
  2. helmet: https://github.com/venables/koa-helmet
  3. logger: https://github.com/danielwpz/logger
  4. bodyparser: https://github.com/koajs/bodyparser
  5. cors: https://github.com/koajs/cors

Examples

  1. Use default middlewares
const common = require('crepecake-common');
const app = new CrepeCake();

app.use(common());
  1. Config default middlewares
const common = require('crepecake-common');
const app = new CrepeCake();

app.use(common({
  helmet: {...helmet options},
  bodyparser: {...bodyparser options}
}));
  1. Use custom middlewares
const common = require('crepecake-common');
const app = new CrepeCake();

app.use(common({
  bodyparser: false,  // set false will disable the default middleware
  myBodyparser: (ctx, next) => {...}  // add your own
}));