Skip to content

Latest commit

 

History

History
27 lines (21 loc) · 618 Bytes

README.md

File metadata and controls

27 lines (21 loc) · 618 Bytes

@malijs/toobject

Mali toObject middleware. If the response object has a toObject function it's executed upon payload. Only applies for UNARY and REQUEST_STREAM call types.

Example

const toObject = require('@malijs/toobject')

function handler(ctx) {
  const obj = {
    email: '[email protected]',
    password: 'mysecret'
  }

  obj.toObject = function() {
    return {
      email: this.email
    }
  }

  ctx.res = obj // password will not be in the payload to client
}

app.use('fn', toObject(), handler)