My Development Notes

Programming Made Easier


NodeJS

Important NPM packages you’ll need to build complex backends with NodeJS

Whether you’re learning backend development (with nodeJS) or trying to build complex back-end while using NodeJS, keep a note of the following NPM packages. You might need all or many of them in you backend development journey. Here they are:

Express JS

Express is a powerful and flexible web framework for NodeJS. It’s designed to make development of web apps and APIs straightforward and efficient by providing some useful set of features.

Some of its key features are middleware functions (with req, res parameters), supporting templating engines like EJS which helps separating application logic from presentation layer. Its also good at error handling and works seamlessly with other NodeJS modules.

Here’s the link to the Express NPM package.

Mongoose

If you work with MongoDB databases, Mongoose is an essential tool for managing them in NodeJS environment.

Mongoose is a MongoDB object modelling tool designed to work in an asynchronous environment. It provides a schema based solution to model your app data. The features of Mongoose are defining schemas, creating models, data validation, middlewares or hooks, query building etc.

Here’s the link to Mongoose NPM package.

Nodemon

Nodemon is a utility tool particularly used during development to monitor any changes to your source code to automatically restart your NodeJS app. It helps save a lot of time during the app development process.

Here’s the link to Nodemon NPM package to help you set up the package and get started.

Express Async Errors

This is an NPM package which you shouldn’t ignore. This is a package that allows you to handle errors in asynchronous functions without having to wrap each and every function in a try-catch block. Set it up once to write clean code without a try-catch block everytime.

Here’s the link to the Express-Async-Errors NPM package.

Validator

The Validator NPM package is a library of string validators and sanitizers. It provides an extensive set of functions to check if a string matches a specific pattern or condition, such as being an email, URL, credit card number, and more. They are also used to sanitize strings, which can be used to filter or clean up input data which is crucial for maintaining data integrity and security in web applications.

Here’s the link to the Validator NPM package.

EJS

EJS or the Embedded Javascript template is a popular template engine for NodeJS. It allows a developer to generate HTML markup with vanilla JavaScript to render dynamic content on the server side.

Here’s the link to the docs.

dotenv

The dotenv NPM package is a very important security package for your backend project. It’s a zero-dependency module that loads environment variables from a .env file into process.env. It separates sensitive configuration details from your actual codebase.

Please not that you always remember to add the .env file to your .gitignore to prevent sensitive information from being stored in your version control system.

Here’s the link to the dotenv NPM package.

bcrypt

The bcrypt is a security package that allows you to hash and salt passwords in NodeJS which makes it difficult for attackers to retrieve passwords even if they somehow gain access to the hashed values of the same. bcrypt also supports Promises, which allows you to use async/await for cleaner and more readable code.

Here’s a link to the documentation of the bcrypt NPM package.

jsonwebtoken

The jsonwebtoken package is a powerful and flexible library for creating and verifying JSON Web Tokens (JWT) in Node.js. By using JWTs, you can implement secure authentication and authorization in your web applications. This ensures that sensitive user data is transmitted securely and can only be accessed by authorized users. The JWTs are a safe and secure way to transmit sensitive information between different parties or users as a JSON object.

You might also need this website which allows you to decode, verify and generate JWT.

Here’s the link to the package.

Nodemailer

Nodemailer is a popular NPM package that allows you to send emails from your server-side applications. It supports various kinds of email services and hence considered a go-to solution for those kinds of services. Setting up can be daunting sometimes so here’s a link to mailtrap which comes in handy.

The link to the docs is here.

CORS

The cors NPM package makes the backend application you’ve created production ready before it’s deployed. It’s a middleware for enabling Cross-Origin Resource Sharing (CORS) in Express.js applications. By using the cors middleware, you can control which domains are allowed to access your resources and customize the behavior of your server’s CORS policy to meet your security requirements.

Here’s the link to the documentation page.

Morgan

Morgan is a middleware NPM package. It’s basically a request logger NPM package which makes our life easy while creating middlewares for our backend.

Know more about Morgan’s installation and usage by clicking the link here.


Posted

in

by

Tags:

Leave a Reply