How to create Restify request or response object from native node raw request and object

106 Views Asked by At

I am building a Web application using Hapi JS. In my application I am using a library which is using the Restify version of request and response objects and I need to pass those values as parameters to one of the functions of the library.

I can retrieve the raw node request and response objects from request.raw object as mentioned here, https://hapi.dev/api/?v=21.0.0-beta.1#-requestraw.

But the thing is that the native node req and res objects are missing the features that Restify has. For example, res.send, res.body, etc.

Also creating own version of request for Hapi overwriting those functions might take forever because in the framework, the request is keeping track of server/ app instance and modifying the same instance of the Prototype of native request object as it is going through the request life-cycle.

How can I convert the native node req and res objects to Restify req and res objects?

0

There are 0 best solutions below