dmbexpress
v1.5.3
Published
Additional help for API developing with node + express.
Downloads
96
Maintainers
Readme
dmbexpress
Additional help for API developing with node + express.
What you can do with dmbexpress
This module is only a help for making frequent coding tasks more easy.
- Easy output for express API. Don't worry. Send to output function anything: text, objects or even error code (it handles node and mongoose errors the best it can, with minimal action). Output is automatically formatted to json.
- Easy error handling in your functions. Don't throw an exception if it's not exceptional! Integrated with output function, so you can send an error text and the corresponding state page code without throw errors.
- Objects handling functions. No need for extra modules if you only want to pick, filter or map an object like you do with arrays, and new features like update an object with other object data using modifiers. More functions coming soon.
Note from the author
When I first created dmbexpress, I was thinking only in my very own needs for node backend API with express. Anyway, it grew up, so more functions where added. And it started to loose sense. So I decided to separate dmbexpress into two different modules: dmboutput and dmbobjects.
Because I wanted to keep dmbexpress running for people who were already using it in their projects, but did not want to have to do double maintenance of the same functions, I modified dmbexpress to be a bridge between the two new modules.
Please, if you want to use the dmbexpress functions, it is preferable that you refer directly to the dmbobjects and dmboutput modules.
Install
npm i dmbexpress -s
Import
const dmb = require('dmbexpress');
Functions overview
Output handling:
Please, for a better perfomance, if you want to use the output handling functions of dmbexpress, refer to dmboutput.
Easy output of what you could want as json API. Don't worry it's string, object, redirection or even an error object. The function will find the best way to output to client.
Error handling:
Please, for a better perfomance, if you want to use the error handling functions of dmbexpress (and many others), refer to dmboutput.
Handle errors and exceptions and output them easy. Full ready for working with dmb.output function, so you can aggregate an code status to the error message.
Tells you if the returned object is an error (both native error and dmbexpress error).
Objects handling:
Please, for a better perfomance, if you want to use the object handling functions of dmbexpress, refer to dmbobjects.
Returns a independent copy of one object.
Obtain a new object with only the properties you want.
Obtain a new object with only the properties you select by a callback.
Obtain a new object with the values modified by your own callback.
Update an object with the data of another object using different modifiers or even your own callback.
Obtain a new object with the data of another object using different modifiers or even your own callback applied over all the resulting object properties.
Validate if an object matches a validation scheme defined by you.