Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-middleware-fetch

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-middleware-fetch

Fetch routes from other express middlewares

  • 1.0.11
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

express-middleware-fetch

Fetch routes from other express middlewares

This creates a fetch function, partially compatible with browser fetch, which can be used to fetch routes from the same express server (e.g. routes generated by other middlewares)

Available function

expressMiddlewareFetch(req:express.Request):((url:string|URL,requestInit?:RequestInit)=>Promise<Response>)&{req:express.Request}

Call this function with an express.Request object to create a fetch function for the same express server as that express.Request object.

The 2nd argument is the same as what is usually passed into fetch.

The express.Request object can later be changed on the returned fetch function.

Example

import * as express from 'express';
import expressMiddlewareFetch from 'express-middleware-fetch';

let req:express.Request;
let req2:express.Request;

let fetcher=expressMiddlewareFetch(req);
fetcher('https://localhost/mypath');
fetcher.req=req2;
fetcher('https://localhost/mypath2');

Building instructions

Delete the line "packageManager": "yarn@4.1.1", from package.json. Delete the line yarnPath: .yarn/releases/yarn-4.1.1.cjs from .yarnrc.yml.

npm i -g yarn
yarn set version 4.1.1
yarn --immutable
yarn build

Keywords

FAQs

Package last updated on 31 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc