Naughty Pterodactyl Maid

    simreq

    1.0.3 • Public • Published

    Welcome to simreq 👋

    Version License: ISC

    simulate routes of an express app with in the app .sometimes we need to execute more than one express endpoints to solve certain problems like sse or push notification .this module lets you simulate any of the routes from anywhere in your express app

    Install

    npm install simreq

    Usage

    var app = express();
    var simreq = require(simreq)
    simreq.init(app);

    Import again on any of the router you have

    var simreq = require(simreq);
     
     
    Router.get("/foo",(req,res,next)=>{
     
        res.send("foo");
     
        simreq.simulator(
          req,
          next,
          {
            url: "/bar",
            query: {
              hi: "hello"
            }
          },
          data => {
     
            //SEND SSE OR DO ANYTHING 
            console.log("Data From /bar", data);
            //Data From /bar {test:true}
          }
        );
     
    })
     
     
    Router.get("/bar",(req,res,next)=>{
     
      res.json({
        test:true
      })
    })
     

    PARMS

    • simreq.simulator(req,next,options,callback): req: http request from the router next: next() from the router options:{}
      { url:"route", query:{}, params:{}, body:{}

      } callback:function (data)

    Author

    👤 Arjun Biju

    Show your support

    Give a ⭐️ if this project helped you!


    This README was generated with ❤️ by readme-md-generator

    Install

    npm i simreq

    DownloadsWeekly Downloads

    6

    Version

    1.0.3

    License

    ISC

    Unpacked Size

    4.54 kB

    Total Files

    4

    Last publish

    Collaborators

    • arrow66