Answer the question
In order to leave comments, you need to log in
Is there a module for implementing intra-program (essentially emulation) requests to an application in Express?
I made a method for req.app, with which you can make GET requests to the application, directly in the program itself without http calls. The method is simple (only GET and only json data) and does not handle errors.
Maybe there is a ready-made module that implements all possible requests to the application?
const http = require("http");
const express = require("express");
express.application.doGet = function getDataFromPath(path) {
return new Promise((resolve, reject) => {
let req = new http.IncomingMessage();
req.method = "GET";
req.url = path;
req.headers = { accept: "application/json" };
let res = new http.ServerResponse(req);
res.json = resolve;
this.handle(req, res, reject);
});
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question