-->

ABOUT US

Our development agency is committed to providing you the best service.

OUR TEAM

The awesome people behind our brand ... and their life motto.

  • Kumar Atul Jaiswal

    Ethical Hacker

    Hacking is a Speed of Innovation And Technology with Romance.

  • Kumar Atul Jaiswal

    CEO Of Hacking Truth

    Loopholes are every major Security,Just need to Understand it well.

  • Kumar Atul Jaiswal

    Web Developer

    Techonology is the best way to Change Everything, like Mindset Goal.

OUR SKILLS

We pride ourselves with strong, flexible and top notch skills.

Marketing

Development 90%
Design 80%
Marketing 70%

Websites

Development 90%
Design 80%
Marketing 70%

PR

Development 90%
Design 80%
Marketing 70%

ACHIEVEMENTS

We help our clients integrate, analyze, and use their data to improve their business.

150

GREAT PROJECTS

300

HAPPY CLIENTS

650

COFFEES DRUNK

1568

FACEBOOK LIKES

STRATEGY & CREATIVITY

Phasellus iaculis dolor nec urna nullam. Vivamus mattis blandit porttitor nullam.

PORTFOLIO

We pride ourselves on bringing a fresh perspective and effective marketing to each project.

  • Connect nodejs with mongodb

     

    Connect node with mongodb

     

     

    Mongodb basic command



    This blog and in upcoming blog we will see mongodb basic and how is it work with installation and after installation we should not face any problem while making Database, collection(table) and using the data in nodejs even whenever we will make API.



    • # Install MongoDB Package
    • # Connect MongoDB with Nodejs
    • # Show data from mongoDB


     

    Now in this blog we will consider about mongoDB basic command which we can use to create Database, collection etc.


     

     What is MongoDB

     

    MongoDB is a popular open-source NoSQL (non-relational) database management system. NoSQL means no structure like it is look like an object while in SQL it is a structure query language like SELECT CustomerName, City FROM Customers; (The SELECT statement is used to select data from a database.) But NoSQL database is useless...NOT completely because of whenever we want add extra column in database then it is possible through NoSQL MongoDB.   

     

    MongoDB installation - CLICK HERE

    MongoDB Basic Command - CLICK HERE

    About MongoDB vs SQL - CLICK HERE

    CRUD in MongoDB - CLICK HERE

     

     



    Object Like - 

     

     

    {
      "_id": {
        "$oid": "659ad46e0382148123c82841"
      },
      "name": "moto G60",
      "brand": "motorola",
      "price": 16500,
      "category": "mobile"
    }
    
    
    

     

     


    MongoDB is a type of database that helps store and manage large amounts of data in a flexible and scalable way. Unlike SQL, MongoDB doesn't require a fixed structure for the data, allowing you to store information in a more versatile format.


    • MongoDB is a NoSQL database.
    • The data stored in a collection
    • Collection don't have row and columns
    • Data is stored in the form of object.




    Now you can understand how can we connect nodejs with the mongodb and how can we use nodejs with the help of mongodb and data insert, update, delete, update dynamic data or make API

     and we have some data in mongodb so after connecting mongodb with the nodejs we can show data from mongodb in nodejs.




    Connect node with mongodb


    we can install this driver as a pkg but it is driver YEAH! because of we can connect nodejs and mongodb with the help of this driver pkg OKAY.

    The official MongoDB driver for Node.js. - https://www.npmjs.com/package/mongodb ( npm i mongodb )

     

     

     Connect node with mongodb

     

     

    Connect MongoDB with Nodejs

     

     Now we will write code in index.js for importing mongodb client and some code.


    1. Importing MongoDB and Setting Up Connection:


    const { MongoClient } = require('mongodb');
    const url = 'mongodb://127.0.0.1:27017';



    Here, you are importing the MongoClient class from the 'mongodb' package, which is the official MongoDB driver for Node.js. You define the connection URL for your MongoDB server. In this case, it's mongodb://127.0.0.1:27017, which is the default address and port for a locally running MongoDB server.



    2. Defining Database and Creating a MongoClient:


    const database = 'e-comm';
    const client = new MongoClient(url);




    You specify the name of the database you want to connect to (e-comm), and then you create a new instance of the MongoClient using the provided connection URL.





    3. Asynchronous Function to Retrieve Data:



    async function getData() {
      let result = await client.connect();
      let db = result.db(database);
      let collection = db.collection('products');
      let response = await collection.find({}).toArray();
      console.log(response);
    }




    # This function, getData, is marked as async, indicating that it contains asynchronous operations.

    # await client.connect();: It connects to the MongoDB server asynchronously and returns a result. This result is an instance of the MongoClient connected to the MongoDB server.

    # let db = result.db(database);: It retrieves the specified database (e-comm in this case) from the connected MongoClient.

    # let collection = db.collection('products');: It gets a reference to the 'products' collection within the 'e-comm' database.

    # let response = await collection.find({}).toArray();: It performs a query to find all documents in the 'products' collection and converts the result to an array.

    # console.log(response);: Finally, it logs the array of documents (or an empty array if there are no documents) to the console.



    4. Calling the getData Function:


    getData();




    The script concludes by calling the getData function. When executed, it will connect to the MongoDB server, retrieve data from the 'products' collection, and log the result to the console.



    Whole Code 

     

    const {MongoClient} = require('mongodb');
    const url = 'mongodb://127.0.0.1:27017'
    
    const database = 'e-comm'
    const client = new MongoClient(url);
    
    async function getData()
    {
      let result = await client.connect();
      let db = result.db(database);
      let collection = db.collection('products');
      let response = await collection.find({}).toArray();
      console.log(response);
    }
    
    getData();
    

     

     

    Run through this command - nodemon index.js or node index.js



     

    Connect node with mongodb

     

     

     


    Disclaimer



    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.




     

  • CRUD operation through Mongosh terminal in mongodb

     

     

    CRUD operation through Mongosh terminal in mongodb

     

     

    Mongodb basic command



    This blog and in upcoming blog we will see mongodb basic and how is it work with installation and after installation we should not face any problem while making Database, collection(table) and using the data in nodejs even whenever we will make API.



    • # How to insert Data collection
    • # How to check inserted Data
    • # How to update Data
    • # How to delete Data


     

    Now in this blog we will consider about mongoDB basic command which we can use to create Database, collection etc.


     

     What is MongoDB

     

    MongoDB is a popular open-source NoSQL (non-relational) database management system. NoSQL means no structure like it is look like an object while in SQL it is a structure query language like SELECT CustomerName, City FROM Customers; (The SELECT statement is used to select data from a database.) But NoSQL database is useless...NOT completely because of whenever we want add extra column in database then it is possible through NoSQL MongoDB.   

     

    MongoDB installation - CLICK HERE

    MongoDB Basic Command - CLICK HERE

    About MongoDB vs SQL - CLICK HERE

     

     

    How to insert Data collection

     

     First we will open MongoDB compass tool actually mongodb compass tool is a only tool, it is used for only provid graphical user interface with CLI. Like how to insert, update, delete etc.



    CRUD operation through Mongosh terminal in mongodb



    Even you can use mongodb in GUI or CLI mode but moslty beginner will using GUI (mongodb compass tool). So, we will start from mongodb start and stop command in command prompt windows.


    net start MongoDB 

    net stop MongoDB

     


    After starting mongoDB  server and you can use this URL mongodb://localhost:27017 for connecting nodejs.we will make Database and collection Name.



    CRUD operation through Mongosh terminal in mongodb


    Successfully created but there is no any data yet becuase of we have just created the Database and its collection.

    You can insert the data via when click on ADD DATA menu and choose option "insert document" and through mongosh CLI mode. But we will go to CLI mode okay!


    • # For choosing DB - use database Name - (replace database name with text)
    • # For insert One Data - db.student.insertOne({name: "atul", class: "one", rollno: 5})

     
     
     


    CRUD operation through Mongosh terminal in mongodb


    For refresh this data in mongoDB (click on refresh button)


    CRUD operation through Mongosh terminal in mongodb


     

    With GUI you can insert the data like this



    CRUD operation through Mongosh terminal in mongodb


     

    You can view the data with three types.



    CRUD operation through Mongosh terminal in mongodb



    You can also view the data via Mongosh CLI


    • # Check data - db.student.find()
    • # vcheck data with particular (_id) - db.student.find({_id : ObjectId("65a784b27d0ea65b469356c6")});



    CRUD operation through Mongosh terminal in mongodb




    How to update Data

     

    we will update the data whenever we want to change the data OKAY! but we will explore through mongosh CLI because you easily update with GUI.


    • # For update data with particular _id - db.student.updateOne({_id: ObjectId("65a784b27d0ea65b469356c6")}, {$set: {name: "kumar atul jaiswal"}})


    Here, first parameter (_id) is a condition like through which do you want to update the data and second parameter is {$set) that's mean what do you want to update like name, class, whatever name has defined in your mongoDB collection's data. Even if you want update the data through name you can. okay!

      



    CRUD operation through Mongosh terminal in mongodb


    How to delete Data


    Through this delete , it might be coming to your mind to delete any data. Hahah Lol! actually you're right.


    Let's do it with CLI mode but you can easily go through GUI mode. 


    • # Delete data via name - db.student.deleteOne({name: "atul"})



    NOTE - keep in mind that this is completely case sensitive, so whenever you enter any parameter or value, write it carefully.




    Disclaimer



    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.


  • mongodb basic command

     

     

    mongodb basic command

     

     

    Mongodb basic command



    This blog and in upcoming blog we will see mongodb basic and how is it work with installation and after installation we should not face any problem while making Database, collection(table) and using the data in nodejs even whenever we will make API.



    • # What is MongoDB
    • # MongoDB vs SQL
    • # MongoDB basic commands


     

    Now in this blog we will consider about mongoDB basic command which we can use to create Database, collection etc.


     

     What is MongoDB

     

    MongoDB is a popular open-source NoSQL (non-relational) database management system. NoSQL means no structure like it is look like an object while in SQL it is a structure query language like SELECT CustomerName, City FROM Customers; (The SELECT statement is used to select data from a database.) But NoSQL database is useless...NOT completely because of whenever we want add extra column in database then it is possible through NoSQL MongoDB.  



    Object Like - 

     

     

    {
      "_id": {
        "$oid": "659ad46e0382148123c82841"
      },
      "name": "moto G60",
      "brand": "motorola",
      "price": 16500,
      "category": "mobile"
    }
    
    
    

     

     

    Set Enviornment and Install MongoDB - CLICK HERE

     


    MongoDB is a type of database that helps store and manage large amounts of data in a flexible and scalable way. Unlike SQL, MongoDB doesn't require a fixed structure for the data, allowing you to store information in a more versatile format.


    • MongoDB is a NoSQL database.
    • The data stored in a collection
    • Collection don't have row and columns
    • Data is stored in the form of object.



     

    MongoDB vs SQL

     

    In SQL - 

    • It is a structured form.
    • There is a row and column form.
    • When we want add extra column after creating table then we face some problem.
    • When an inbox is optional where any user may or not fill in that box, memory may be wasted in that database.

     

     

    mongodb basic command

     

     


    In MongoDB - 

    • It is an unstructured form.
    • There is a collection form.
    • When we want add extra column and rows we can do it easily because it is in object form.
    • Here any user can fill the data as per his choice less or more.

     


     

    mongodb basic command

     

      

     

    MongoDB basic commands

     

    You can use mongodb in GUI or CLI mode but moslty beginner will using GUI (mongodb compass tool). So, we will start from mongodb start and stop command in command prompt windows.


    net start MongoDB 

    net stop MongoDB

     


    mongodb basic command


    After starting mongoDB  server and you can use this URL mongodb://localhost:27017 for connecting nodejs.



    In GUI Mode


    Open MongoDB compass tool and simple click on connect or save or connect button.



    mongodb basic command


     

    And copy the accessing URL.

     

     


    mongodb basic command


    Now click on icon and create a database name and collection name.



    mongodb basic command


    CLI MODE


    Finally we have to start create database name, collection, read, update, delete through command line interface in mongoose terminal.


    Simple click on mongoose button on MongoDB compass tool.



    mongodb basic command


    1. show dbs   (database check)
    2. use youtube  (create db)
    3. db.createCollection('videos')  (create table)
    4. show collections       (check table)
    5. db.videos.drop()  (to delete table)
    6. db.dropDatabase()      (to delete database)
    7. use admin (another db)



    mongodb basic command


    Still database not created because we have not created the table yet, even the name of database is not being shown.If you have used SQL  then you would know that it also does not show a database. Unless you create a table in it.



    mongodb basic command


    For creating table you can use db.createCollection('videos') 

     

     

    mongodb basic command

     

     Just like that you can create collection, show collection, drop the collection and database etc.



     

    mongodb basic command

     

     Insert Data

     

    You can insert data in mongodb by CLI mode through this command db.products.insertOne({name: 'moto G60', brand: 'motorola', price: 1800, category: 'mobile'})

     

     

    mongodb basic command

     

     db.products.insertOne({name: 'moto G60', brand: 'motorola', category: 'mobile', price: {actualAmount: 20000, discount: 2000}})

     

     

    mongodb basic command

     


    mongodb basic command


    UpdateOne


    db.products.updateOne({name: "moto G60"}, {$set: {brand: "oppo"}})


    mongodb basic command



    DeleteOne


    db.products.deleteOne({brand: "moto G60"})



    mongodb basic command




    Disclaimer



    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.




  • Set environment for mongodb

     

    Set environment for mongodb

     

    Set environment for mongodb



    This blog and in upcoming blog we will see mongodb basic and how is it work with installation and after installation we should not face any problem while making Database, collection(table) and using the data in nodejs even whenever we will make API.



    • # Download DB
    • # Install MongoDB
    • # Set Environment for Mongo
    • # MongoDB compass Tool




    MongoDB is a popular open-source NoSQL (non-relational) database management system. NoSQL means no structure like it is look like an object while in SQL it is a structure query language like SELECT CustomerName, City FROM Customers; (The SELECT statement is used to select data from a database.) But NoSQL database is useless...NOT completely because of whenever we want add extra column in database then it is possible through NoSQL MongoDB.  



    Object Like - 

     

     

    {
      "_id": {
        "$oid": "659ad46e0382148123c82841"
      },
      "name": "moto G60",
      "brand": "motorola",
      "price": 16500,
      "category": "mobile"
    }
    
    
    

     

     


    MongoDB is a type of database that helps store and manage large amounts of data in a flexible and scalable way. Unlike SQL, MongoDB doesn't require a fixed structure for the data, allowing you to store information in a more versatile format.


    • MongoDB is a NoSQL database.
    • The data stored in a collection
    • Collection don't have row and columns
    • Data is stored in the form of object.




    Download DB and Install MongoDB

     

    1) Visit the official MongoDB website: https://www.mongodb.com/try/download/community


    2) On the MongoDB Download Center page, you'll find different versions of MongoDB. Choose the "Community Server" version, which is free and open-source.


    3) Scroll down to the "Community Server" section, and you'll see various download options based on your operating system. Click on the "Windows" tab.


    4) Select the version of MongoDB you want to download. Typically, the latest stable version is recommended.


    5) Choose the installation package that suits your Windows version (either 32-bit or 64-bit). If you're unsure about your Windows version, you can check it by right-clicking on "This PC" or "My Computer" and selecting "Properties."


    6) Click the "Download" button to start the download.


    7) Once the download is complete, open the installer executable file (.msi extension) you just downloaded.



    Set environment for mongodb





    8) Follow the installation wizard's instructions. You can choose the installation directory and other configuration options during the installation process. It is very simple process.


    9) MongoDB Compass is a graphical user interface (GUI) for MongoDB. If you want to install it as well, make sure to check the option during the installation process.

     

    Direct Downloadable link of Compass MongoDB GUI - CLICK HERE 

     


    10) After completing the installation, MongoDB will be installed on your Windows machine. You can start using it to create databases, collections, and perform various database operations.




    Set Environment for Mongo


    After installing mongodb and GUI compass software lets check is the mongodb path set or not. Okay for this simply search environment variables in windows icon and open it.



    Set environment for mongodb


    Click on environment variables and choose path and edit.

     

     

    Set environment for mongodb

     


    as you can see that path is already set when we install mongodb okay.



    Set environment for mongodb


    If it is not set then go to directory where mongodb installed. For this C:\Program Files\MongoDB\Server\6.0\bin and copy this directory and paste in path section like this - in above picture.



    MongoDB compass Tool


    MongoDB Compass is the official graphical user interface (GUI) for MongoDB. It provides a visual way to interact with your MongoDB databases and collections, making it easier to explore and manipulate your data.



    Set environment for mongodb






    Disclaimer



    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.



  • Route Level in Middleware ejs


    Route Level in Middleware ejs

     

    Middleware in Expressjs

     

    Hello viewers, whats up!! Here i am back again with the new series of  Nodejs. Node.js is an open-source, cross-platform JavaScript runtime environment that allows developers to run JavaScript code outside of a web browser. It is built on the V8 JavaScript runtime engine, which is the same engine that powers the Google Chrome browser. 

    Node.js is commonly used for building APIs (Application Programming Interfaces). You can create RESTful APIs or GraphQL APIs using Node.js to handle HTTP requests and serve data to client applications.

     

    Key features of Node.js include:

     

    # Asynchronous - Node.js is designed to be asynchronous, meaning it can handle a large number of concurrent connections without the need for multithreading.

    # Single-threaded, Non-blocking I/O - Node.js uses a single-threaded event loop to manage asynchronous operations.

    # npm (Node Package Manager): npm is the default package manager for Node.js, allowing developers to easily manage and install libraries and dependencies for their projects.

    # Server-Side Development: Node.js is commonly used for server-side development, where it excels at handling real-time, data-intensive applications, such as chat applications, online gaming, and streaming services.

     

    But Why we are using Expressjs Here, just because of incase if you want to make API using nodejs directly then its a very complex method to create API and integrate directly thats why we are using Expressjs framework and in this framework with the help, you can create RESTful API easily.




    Why we need of middleware in Expressjs ?


    In express.js, middleware functions have access to the request object ('req'), the response object ('resp'), and the next middleware function in the application's request-response cycle. They can perform various task, modify the request and response object, end the request-response cycle, and call the next middleware in the stack.

     

     Middleware Types ?


    • Application-level middleware
    • Router level middleware
    • Error-handling middleware
    • Built-in middleware
    • Third-party middleware

     

       

    Route Level Middleware

     

    Before stating route level, we have already told you about Application level middleware. CLICK HERE for more info. 

    Route level middle that is applied specifically to a particular route or group of routes in a web application. This allows developers to define middleware that is only executed for certain routes, providing a more fine-grained control over the application's behavior.

     

     

    How to implement on a particular route ?


    If you carefully discuss saw our about previous blog then we already know about request filter like we were used app.use(requestFilter);


    const reqFilter = (req, resp, next) => {
       console.log("reqFilter")
    next();
    }
    
    


    const express = require("express");
    const app = express();
    
    
    
    const reqFilter = (req, resp, next) => {
        if (!req.query.age) {
          resp.send("Please provide your age");
        } else if (req.query.age < 18) {
          resp.send("You can't access this becuase of you are minor ");
        //   Please provide your age as a parameter like ?age=18
        } else {
          next();
        }
      };
    
      app.use(reqFilter);
    
    app.get("/", (req, resp) => {
        resp.send("Welcome to Home Page")
      });
      
      app.get("/user", (req, resp) => {
        resp.send("Welcome to user page");
      });
      
    
    
    
    app.listen(5000);
    
    



    But now we want only apply middleware on particular page so don't use app.use(requestFilter); . Let's check it how we can implement on a particular page.


    app.get("/user", reqFilter, (req, resp) => {
        resp.send("Welcome to User Page")
      });
      



    Whole Code

     

    
    


    const express = require("express");
    const app = express();
    
    
    
    const reqFilter = (req, resp, next) => {
        if (!req.query.age) {
          resp.send("Please provide your age");
        } else if (req.query.age < 18) {
          resp.send("You can't access this becuase of you are minor ");
        //   Please provide your age as a parameter like ?age=18
        } else {
          next();
        }
      };
    
     
    
    app.get("/", (req, resp) => {
        resp.send("Welcome to Home Page")
      });
      
      app.get("/user", reqFilter, (req, resp) => {
        resp.send("Welcome to user page");
      });
      
    
    
    
    app.listen(5000);
    
    

     

     

     

    Route Level in Middleware ejs

     

    Make middleware in different file

     

    Why we need of separate file for this because of if we have too much routes in index.js or good pratice for us to make a separate file then it will be very complexity so for this you can first make a file in the same place where that you have index.js file so create a middleware.js file and code it.

     

     

    module.exports = reqFilter = (req, resp, next) => {
        if (!req.query.age) {
          resp.send("Please provide your age");
        } else if (req.query.age < 18) {
          resp.send("You can't access this becuase of you are minor ");
        //   Please provide your age as a parameter like ?age=18
        } else {
          next();
        }
      };
    

     

     

     Here above in the code only one line we have to added like module.exports = 

     

      

    const express = require("express");
    const app = express();
    
    const reqFilter = require('./middleware');
    
    route.use(reqFilter);
     app.get("/", (req, resp) => {
        resp.send("Welcome to Home Page")
      });
      
      app.get("/user", reqFilter, (req, resp) => {
        resp.send("Welcome to user page");
      });
      
    app.listen(5000);
    
    

     

     

     

    Route Level in Middleware ejs



     Implement Route more Than one page except one Page


     

    const express = require("express");
    const app = express();
    
    const reqFilter = require('./middleware');
    
    const route = express.Router();
    
    //app.use(reqFilter);
    
    route.use(reqFilter);
    
    app.get("/", (req, resp) => {
        resp.send("Welcome to Home Page")
      });
      
      route.get("/user", (req, resp) => {
        resp.send("Welcome to user page");
      });
      
      route.get("/contact", (req, resp) => {
        resp.send("Welcome to contact page");
      });
      
    
      app.use('/', route);
       
    app.listen(5000);
    
    

     

     

     

    Route Level in Middleware ejs

     

    Here as you can see this only home page is shown as normal page except user or contact page.

     


    # Install redux and saga packages - CLICK HERE

    # Make reducer wrapper - CLICK HERE

    # Action in reducer - CLICK HERE

    # Reducer in redux - CLICK HERE

    # Switch Stmt in redux - CLICK HERE

    # Get data in component from redux - CLICK HERE 

    # Remove from cart - CLICK HERE 

    # Add Redux Toolkit in react redux saga - CLICK HERE  

    # Configure MiddleWare saga - CLICK HERE   

    # Call API with Saga and Set Result in react redux saga - CLICK HERE    

    # Product list ui with API data in react redux saga - CLICK HERE    

    # Remove to Cart with ID react redux saga - CLICK HERE     

    # Add Routing and Make Cart Page - CLICK HERE   

    # Show Added To Cart Product with Price Calculation  - CLICK HERE  

     

    Disclaimer



    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.

     

     


  • Middleware in Expressjs

     

    Middleware in Expressjs

     

    Middleware in Expressjs

     

    Hello viewers, whats up!! Here i am back again with the new series of  Nodejs. Node.js is an open-source, cross-platform JavaScript runtime environment that allows developers to run JavaScript code outside of a web browser. It is built on the V8 JavaScript runtime engine, which is the same engine that powers the Google Chrome browser. 

    Node.js is commonly used for building APIs (Application Programming Interfaces). You can create RESTful APIs or GraphQL APIs using Node.js to handle HTTP requests and serve data to client applications.

     

    Key features of Node.js include:

     

    # Asynchronous - Node.js is designed to be asynchronous, meaning it can handle a large number of concurrent connections without the need for multithreading.

    # Single-threaded, Non-blocking I/O - Node.js uses a single-threaded event loop to manage asynchronous operations.

    # npm (Node Package Manager): npm is the default package manager for Node.js, allowing developers to easily manage and install libraries and dependencies for their projects.

    # Server-Side Development: Node.js is commonly used for server-side development, where it excels at handling real-time, data-intensive applications, such as chat applications, online gaming, and streaming services.

     

    But Why we are using Expressjs Here, just because of incase if you want to make API using nodejs directly then its a very complex method to create API and integrate directly thats why we are using Expressjs framework and in this framework with the help, you can create RESTful API easily.




    Why we need of middleware in Expressjs ?


    In express.js, middleware functions have access to the request object ('req'), the response object ('resp'), and the next middleware function in the application's request-response cycle. They can perform various task, modify the request and response object, end the request-response cycle, and call the next middleware in the stack.


    Apply middleware


     

    const reqFilter = (req, resp, next) => {
       console.log("reqFilter")
    next();
    }
    
    

     

     
    # req, resp for modify in middleware

    # next as a function we will consider


    NOTE - if we not consider next(); then our page like (home, about, profile page) not move ahead.

     

    Full Implementation of Middleware

     

    Here we first write simple get req and resp (request, response) from static page after that we implement middleware.

     

     

    const express = require("express");
    const app = express();
    
    
    app.get("/", (req, resp) => {
        resp.send("Welcome to Home Page")
      });
      
      app.get("/user", (req, resp) => {
        resp.send("Welcome to user page");
      });
      
    
    
    
    app.listen(5000);
    
    

     

    Run by this command nodemon index.js or node index.js 

     

     

    Middleware in Expressjs

     


    Middleware in Expressjs

     

     

     

    const express = require("express");
    const app = express();
    
    
    
    const reqFilter = (req, resp, next) => {
        if (!req.query.age) {
          resp.send("Please provide your age");
        } else if (req.query.age < 18) {
          resp.send("You can't access this becuase of you are minor ");
        //   Please provide your age as a parameter like ?age=18
        } else {
          next();
        }
      };
    
      app.use(reqFilter);
    
    app.get("/", (req, resp) => {
        resp.send("Welcome to Home Page")
      });
      
      app.get("/user", (req, resp) => {
        resp.send("Welcome to user page");
      });
      
    
    
    
    app.listen(5000);
    
    

     

     

    Middleware in Expressjs

     

     

     


    # Install redux and saga packages - CLICK HERE

    # Make reducer wrapper - CLICK HERE

    # Action in reducer - CLICK HERE

    # Reducer in redux - CLICK HERE

    # Switch Stmt in redux - CLICK HERE

    # Get data in component from redux - CLICK HERE 

    # Remove from cart - CLICK HERE 

    # Add Redux Toolkit in react redux saga - CLICK HERE  

    # Configure MiddleWare saga - CLICK HERE   

    # Call API with Saga and Set Result in react redux saga - CLICK HERE    

    # Product list ui with API data in react redux saga - CLICK HERE    

    # Remove to Cart with ID react redux saga - CLICK HERE     

    # Add Routing and Make Cart Page - CLICK HERE   

    # Show Added To Cart Product with Price Calculation  - CLICK HERE  

     

    Disclaimer



    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.

     


  • Make Common Header for Dynamic Pages in EJS

     

    Make Common Header for Dynamic Pages in EJS
     

     

    Make Common Header for Dynamic Pages in EJS

     

    Hello viewers, whats up!! Here i am back again with the new series of  Nodejs. Node.js is an open-source, cross-platform JavaScript runtime environment that allows developers to run JavaScript code outside of a web browser. It is built on the V8 JavaScript runtime engine, which is the same engine that powers the Google Chrome browser. 

    Node.js is commonly used for building APIs (Application Programming Interfaces). You can create RESTful APIs or GraphQL APIs using Node.js to handle HTTP requests and serve data to client applications.

     

    Key features of Node.js include:

     

    # Asynchronous - Node.js is designed to be asynchronous, meaning it can handle a large number of concurrent connections without the need for multithreading.

    # Single-threaded, Non-blocking I/O - Node.js uses a single-threaded event loop to manage asynchronous operations.

    # npm (Node Package Manager): npm is the default package manager for Node.js, allowing developers to easily manage and install libraries and dependencies for their projects.

    # Server-Side Development: Node.js is commonly used for server-side development, where it excels at handling real-time, data-intensive applications, such as chat applications, online gaming, and streaming services.

     

    But Why we are using Expressjs Here, just because of incase if you want to make API using nodejs directly then its a very complex method to create API and integrate directly thats why we are using Expressjs framework and in this framework with the help, you can create RESTful API easily.




    Why we need of EJS ?

    Here we gonna discuss about ejs template because of you are all aware about our previous blog where we have to written static page name where we don't need to implement database and in static page for not possible but for this template you can Database connectivity with dynamic page.

     

     

    Make login.ejs Page in Views Folder


     

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Login Page</title>
    </head>
    <body>
    
        <h1>This is our Login Page</h1>
        
    </body>
    </html>
    

     

     

     

    Make Common Header for Dynamic Pages in EJS

     

     

     Just like login.ejs you can create so many file with (.ejs) extension.



    Make Common Folder

     

    Here we will make folder name as common folder in views folder and inside common folder create a new file with the extension of (.ejs) Navbar.ejs . and we will use this navbar.ejs 's menu in all the profile.ejs, login.ejs, about.ejs etc file.

     

     

    Navbar.ejs

     

     

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Navbar</title>
        <style>
            .navbaritem {
                display: flex;
                list-style: none;
                font-size: 20px;
               
            }
            li {
                margin-left: 10px;
            }
        </style>
    </head>
    <body>
    
    
        <div>
            <nav class="navbaritem">
                <li>Navbar</li>
                <li>Navbar</li>
                <li>Navbar</li>
            </nav>
        </div>
        
    </body>
    </html>
    
    

     

     

     

    Get Data of  Navbar.ejs in Every file (.ejs) 

     

     <%- include('common/navbar'); %>
    

     

     Unescaped raw output with <%- %>

     

     

     

    Make Common Header for Dynamic Pages in EJS

     

     

    Make Common Header for Dynamic Pages in EJS

     

     


    # Install redux and saga packages - CLICK HERE

    # Make reducer wrapper - CLICK HERE

    # Action in reducer - CLICK HERE

    # Reducer in redux - CLICK HERE

    # Switch Stmt in redux - CLICK HERE

    # Get data in component from redux - CLICK HERE 

    # Remove from cart - CLICK HERE 

    # Add Redux Toolkit in react redux saga - CLICK HERE  

    # Configure MiddleWare saga - CLICK HERE   

    # Call API with Saga and Set Result in react redux saga - CLICK HERE    

    # Product list ui with API data in react redux saga - CLICK HERE    

    # Remove to Cart with ID react redux saga - CLICK HERE     

    # Add Routing and Make Cart Page - CLICK HERE   

    # Show Added To Cart Product with Price Calculation  - CLICK HERE  

     

    Disclaimer



    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.

     




  • WHAT WE DO

    We've been developing corporate tailored services for clients for 30 years.

    CONTACT US

    For enquiries you can contact us in several different ways. Contact details are below.

    Hacking Truth.in

    • Street :Road Street 00
    • Person :Person
    • Phone :+045 123 755 755
    • Country :POLAND
    • Email :contact@heaven.com

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.