senecajs/seneca-web-adapter-koa2

payload lose params

Closed this issue · 1 comments

when I use seneca+koa , try Web Server Integration(http://senecajs.org/getting-started/) , run failure.
but same plugin code run with seneca-web-adapter-express is OK.
my plugin code :

module.exports = function api(options) {

  var valid_ops = { sum:'sum', product:'product' }

  this.add('role:api,path:calculate', function (msg, respond) {
    console.log("msg",msg);

    // failure this line
    var operation = msg.args.params.operation

    var left = msg.args.query.left
    var right = msg.args.query.right
    this.act('role:math', {
      cmd:   valid_ops[operation],
    //   cmd:   valid_ops['sum'],
      left:  left,
      right: right,
    }, respond)
  })


  this.add('init:api', function (msg, respond) {
    this.act(
        'role:web',{
            routes:[{
                prefix: '/api',
                pin: 'role:api,path:*',
                map: {
                    calculate: {
                        GET:true,
                        suffix:'/:operation'
                    }
                }
            }]
        },
        respond
    )
  })

}

I found msg.args.params is null,check the seneca-web-adapter-koa2 sourcecode,because not set params prop,so I modify code "seneca-web-adapter-koa2.js" ,my code run OK.

        let params = ctx.params;

        const payload = {
          request$: ctx.request,
          response$: ctx.response,
          args: {body, query,params}
        }

Sorry about the wait on this one - fixed in v1.1.0