Introduction
In this article, we make a simple user login register system. Them, we apply authorization for it using a middleware.
What is authorization?
Authorization is a security mechanism to determine access levels or user/client privileges related to system resources including files, services, computer programs, data and application features. This is the process of granting or denying access to a network resource that allows the user access to various resources based on the user's identity.
Project Structure
|----------config
| |------- authorize.js
|
|----------models
| |--------- user.js
|
|----------routes
| |-------- users.js
|
|----------app.js
|
|----------package.json
Setup Folder
Create a new folder for the project
- To open the console, type the following command followed by the folder name
# mkdir auth
- Change to the current folder
Setup Node In-Folder
- we can setup node in our folder by the following command
# npm init -y
- This command will generate a package.json file which shows that node is set up in our environment.
- The file will look like this
- {
- "name": "auth",
- "version": "1.0.0",
- "description": "",
- "main": "index.js",
- "scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
- },
- "author": "",
- "license": "ISC",
- "dependencies":{}
- }
Install Packages
- We can install package for the application using the following command
Some info about packages



Join the conversation! Your thoughts help the community grow.