A small (< 60 loc) helper library to handle response calls in express like frameworks.
npm install handle-res
The handleRes module is split into 2 main methods,
The reason that
.reject sends back the
Status: OK http code is to allow developers to create their own failure context. Use
.reject when you are able to determine the error. For example, if a user enters a wrong password to your
verifyLogin route, you should do:
Of course the above could be made more sophisticated via automatic error codes, custom error types, etc.
const express =const handleRes =const app =appapp