0.0.6 • Published 6 years ago

onion-knife v0.0.6

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

onion-knife

Build Status

parse your data use middleware, thanks koa team;

install

  • npm install onion-knife --save
  • yarn add onion-knife

api

  • static: Onion.singleton() return Onion singleton instance
  • onion.use(fn) return this: add middleware to stack
  • onion.spicy(data) return Promise : start parse data

test

npm test
# or
yarn test

coverage

npm run coverage
#or
yarn coverage

example

// middleware
const md1 = async function(meta, next) {
  console.log(meta) // { data: { hello: 'cheerfyt' }, state: {} }
  meta.user = 'cheerfyt'
  const ret = await next()
  console.log('md1: %j, %s', meta, ret) //  md1: {"data":{"hello":"cheerfyt"},"state":{},"user":"cheerfyt"} enjoy onion
}

const md2 = async function(meta, next) {
  console.log('md2: %j', meta.user) // output: md2: "cheerfyt"
  return 'enjoy onion'
}

// instance
const onion = new Onion()
onion
  .use(md1)
  .use(md2)
  .spicy({ hello: 'cheerfyt' })

TODO

  • more options support
  • ...
0.0.6

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago