npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dmbexpress

v1.5.3

Published

Additional help for API developing with node + express.

Downloads

96

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.

dmb.output

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.

dmb.error

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.

dmb.isError

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.

dmb.copy

Returns a independent copy of one object.

dmb.pick

Obtain a new object with only the properties you want.

dmb.filter

Obtain a new object with only the properties you select by a callback.

dmb.map

Obtain a new object with the values modified by your own callback.

dmb.update

Update an object with the data of another object using different modifiers or even your own callback.

dmb.fusion

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.

dmb.validate

Validate if an object matches a validation scheme defined by you.