Mongoose, Express, JWT Explanation

Mongoose, Express, JWT Explanation

1. Explain Mongoose!

Answer: Mongoose is a wrapper around MongoDB. To install Mongoose to our project we have to open our terminal and run the command “npm i mongoose”. We can also install nodemon which will automatically refresh our page and it’s optional. To connect mongoose to your project you must require mongoose to your project.
const mongoose = require(“mongoose”)
mongoose.connect(“mongodb://localhost/testdb”)
There are 3 things to understand in mongoose first is a schema, which represents the structure of a particular document. Secondly, a Model is like an individual user object in a database. Lastly the query, by using query we are just interacting with the MongoDB database.
We can use all MongoDB methods in mongoose. So, Mongoose gives us a simple schema-based solution to model our application data. It includes built-in type casting, validation, query building, business logic hooks and more, out of the box.
Finally, we can say, Mongoose acts as an intermediate between MongoDB and server-side language just like NodeJS.

2. Explain ExpressJS!

Answer: Express in minimalist web framework for NodeJS. What mean by that is we can easily create servers by using Express. And another cool thing is that Express uses javascript. So, we can use javascript in our frontend and backend. To use ExpressJS use must install NodeJS on your machine. Express.js simplifies development and makes it easier to write secure, modular, and fast applications. You can do all that in plain old NodeJS.

3. What is JWT?

Answer: JWT is commonly used for managing authorization. The idea behind JWT is to create a standard way for two parties to communicate securely. There is an open industry standard specification which is RFC 7519. Which outlines how JWT should be structured. How to use it for exchanging information.