restify-await-promise
Converts restify routes to support async/await and returned promises. Works with Restify 4.x through 6.x. May work with Restify 7+.
Supported Restify Versions
- Fully Supported
- 4.x to 5.x
- Probably Works
- 6.x
- Partially Compatible
- 7.x+
NOTE: Does not support Restify 7+ conditionalRouteHandler
- 7.x+
Usage
const restify = ;const restifyPromise = ; const server = restify; //Allows you to manipulate the errors before restify does its workconst alwaysBlameTheUserErrorTransformer = { //Always blame the user exceptionThrownByRoutestatusCode = 400; return exceptionThrownByRoute; } const options = logger: yourLogger //Optional: Will automatically log exceptions errorTransformer: alwaysBlameTheUserErrorTransformer //Optional: Lets you add status codes ; restifyPromise; // Options is not required //Async function, automatically calls send with the returned object and nextserver; //Promise functionserver; //Existing restify methodserver; server;
Installation
$ npm install --save restify-await-promise