Skip to content

rockdai/koa-transform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

koa-transform

Build Status Coverage Status

Transform request parameters style

Useage

const Koa = require('koa');
const transform = require('koa-transform');

const app = new Koa();
app.use(transform());

app.use(async ctx => {
  // the `ctx.query` and `ctx.request.body` 
  // will be transformed to camel style
  // when request /?post_id=1
  ctx.query; // -> { postId: 1 }

  // the data set to `ctx.body`
  // will be transformed to snake style
  ctx.body = { userId: 1 } // -> { user_id: 1 }
});

About

Transform request parameters style

Resources

License

Stars

Watchers

Forks

Packages