-->

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.

Showing posts with label middleware. Show all posts
Showing posts with label middleware. Show all posts
  • 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.

     


  • 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.