As an API project, dipakkr/node-auth has picked up 88 stars on GitHub (JavaScript). Implementing Authentication in NodeJS With Express and JWT - CodeLab #1
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
I am starting a CodeLab series in which I will building something cool and sharing with the community.
Today, We are going to implement Authentication API in Node using JWT, express, and MongoDB.
I advise you to follow the table of content and don't miss any steps. I will provide the full app code link at the end.
Table of Content
1. Introduction
2. Prerequisites
3. Tools and Packages Required
4. Initiate Project
5. Setup MongoDB Database
6. Configure User Model
7. User Signup
8. User Login
9. Get LoggedIn User
10. Conclusion
1. Introduction
User Authentication contains various steps, please checkout this flowchart to know more. We will be using this flow to build authentication system in our application.
2. Prerequisites
You should have prior knowledge of javascript basics, nodejs. Knowledge of ES6 syntax is a plus. And, at last nodejs should be installed on your system.
3. Packages Required
You will be needing these following 'npm' packages.
express
Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications
express-validator
To Validate the body data on the server in the express framework, we will be using this library. It's a server-side data validation library. So, even if a malicious user bypasses the client-side verification, the server-side data validation will catch it and throw an error.
body-parser
It is nodejs middleware for parsing the body data.
bcryptjs
This library will be used to hash the password and then store it to database.This way even app administrators can't access the account of a user.
jsonwebtokenjsonwebtoken will be used to encrypt our data payload on registration and return a token. We can use that token to authenticate ourselves to secured pages like the dashboard. There would also an option to set the validity of those token, so you can specify how much time that token will last.
mongoose
Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Mongoose supports both promises and callbacks.
4. Initiate Project
We will start by creating a node project. So, Create a new folder with the name 'node-auth' and follow the steps below. All the project files should be inside the 'node-auth' folder.
npm init
npm init will ask you some basic information about project. Now, you have created the node project, it's time to install the required packages. So, go ahead and install the packages by running the below command.
So, the Mongo Server Address(MongoURI) should look like this. Don't try to connect on my MongoURI. It's just a dummy username & password. :smile::smile:
Yayy !! You have successfully created an authentication API in nodejs. Now, You can go ahead and test the /user/me endpoint after logging in.
How to Test the application?
PostMan is required for Testing the API. If you don't have PostMan installed first, install it.
First, register the user or login if you are already registered.
From step 1, you will get a token. Copy that token and put in the header.
Hit Submit
Here is a preview of testing.
10. Conclusion
In this CodeLab - 1, we covered authentication in nodejs using express, jsonwebtoken and MongoDB. We learned about how to write middleware.
Here is the link of full code for this CodeLab: https://github.com/dipakkr/node-auth.
Also, I would love to know what else you want to cover in next CodeLabs.
If you face in problem in running this application, let me know in the comments. Don't forget to give your feedback. Getting feedback helps me improve.
I write about new stuff almost daily. Please follow me on Twitter | Instagram
If you liked the content, Give a star on repo. And, like the post.
The most recent commit recorded on dipakkr/node-auth was 3.9 years ago, based on the GitHub push timestamp. The repository has 42 forks — one of the better signals of community interest.
How does dipakkr/node-auth compare to other API projects?
dipakkr/node-auth is tracked by TopGit in the API category, with 88 GitHub stars and written in JavaScript. Browse the API topic page on TopGit to compare it against similar projects by stars and activity.
How many stars does dipakkr/node-auth have?
dipakkr/node-auth has 88 GitHub stars — refresh the page for the live number, or check github.com/dipakkr/node-auth. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
What is dipakkr/node-auth?
dipakkr/node-auth (dipakkr/node-auth) is a JavaScript project on GitHub. From the project's own README: Implementing Authentication in NodeJS With Express and JWT - CodeLab #1
What language is dipakkr/node-auth written in?
dipakkr/node-auth is written primarily in JavaScript. GitHub's language field is based on the largest share of bytes in the default branch.
What topics is dipakkr/node-auth associated with?
GitHub's repository topics for dipakkr/node-auth: "api", "authentication", "bcryptjs", "jwt-authentication", "login-signup", "nodejs", "user-authentication". TopGit's editorial category is API.
Why is dipakkr/node-auth categorized under API?
TopGit places dipakkr/node-auth in the API category based on its GitHub topics and description (tagged: "api", "authentication", "bcryptjs"). Categories are assigned from real repository metadata, not editorial guesswork.
Read full README in the tab above.
Still deciding about node-auth?
One click hands the question to an AI along with this page — see what it says about node-auth.