A
A
aleksey2017-05-23 13:33:40
RESTful API
aleksey, 2017-05-23 13:33:40

inversify-restify-utils empty context and body in controller?

I was trying to run inversify-restify-utils and ran into a problem. Request context and req.body variable are not defined.

@Controller('/users')
@injectable()
export class UsersController implements interfaces.Controller {

  @Post('/')
  createUser(req: restify.Request, res: restify.Response, next: restify.Next) {
    console.log(req.body); // undefined
  }
}

My server.ts:
// to get query params in req.query
this.server.use(restify.acceptParser(this.server.acceptable));
// to get passed json in req.body
this.server.use(restify.bodyParser());

this.server.post('/test', (req, res, next) => {
  console.log(req.body); // ok
  next();
});

Any ideas?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question