rock-req

5.1.3 • Public • Published

rock-req logo

Rock-req

⭐️⭐️ Ensure your HTTP requests always reach their destination as efficiently as possible! ⭐️⭐️

Tested on Mac, Linux, Windows with NodeJS 16, 18, 19, 20

npm ci javascript style guide

🔥 Why?

In most existing libraries (2023):

  • Managing reliable retries is difficult, tricky with streams and not battle-tested
  • Using multiple forward proxies has several benefits like higher availability and increased bandwidth but Intercepting retries to use another Egress controller between two requests is not possible.
  • Many request libraries are heavy: node-fetch, superagent, needle, got, axios, request
  • Lightweight alternatives are not as light as they claim due to dependencies (simple-get, tiny-req, puny-req, phin, ...)

⚡️ Rock-req solves these problems with only 150 lines of code and zero dependencies

It also supports many features:

  • Follows redirects
  • Handles gzip/deflate/brotli responses
  • Modify defaults
  • Extend and create new instances
  • Automatically destroy input/output stream on error and premature close event
  • Advanced retries
  • URL Rewrite
  • Ultra-fast (> 20k req/s)
  • Keep Alive by default (3000ms)
  • Composable
  • Timeouts
  • HTTPS / HTTP
  • Composes well with npm packages for features like cookies, proxies, form data, & OAuth
  • Keep 98% of the simple-get API (fork source)

When the callback is called, the request is 100% finished, even with streams.

🚀 Benchmark Rock-req vs got, axios, node-fetch, phin, simple-get, superagent, ...

Stop using "slow by-default" and "false-light" HTTP request libraries!

Library NodeJS 16 NodeJS 18 NodeJS 20* Size deps inc.
rock-req 🙋‍♂️ 22816 req/s 21797 req/s 21964 req/s 144 LOC
simple-get 2937 req/s 3260 req/s 21258 req/s 317 LOC
axios 5090 req/s 4910 req/s 3196 req/s 13983 LOC
got 2163 req/s 1762 req/s 9961 req/s 9227 LOC
fetch 2101 req/s 2102 req/s 2020 req/s 13334 LOC
request 2249 req/s 1869 req/s 15815 req/s 46572 LOC
superagent 2776 req/s 2100 req/s 2895 req/s 16109 LOC
phin 3178 req/s 1164 req/s 21299 req/s 331 LOC
undici* 24095 req/s 24378 req/s 24191 req/s 16225 LOC

NodeJS 20 activates HTTP keep-alive by default, like rock-req

undici is a low-level API, faster alternative to the native NodeJS http module. It is the glass ceiling limit for NodeJS.

rock-req uses only the native NodeJS http module and provides many high-level features, a lot more than phin and simple-get with fewer lines of code.

Tested on Macbook Pro M1 Max

Install

  npm install rock-req

Documentation

The full documentation is here to reduce Node package file size.

Supporters

This packaged in maintained by Carbone:

Carbone.io logo

Thank you Feross Aboukhadijeh, creator of simple-get

Package Sidebar

Install

npm i rock-req

Weekly Downloads

67

Version

5.1.3

License

MIT

Unpacked Size

14.8 kB

Total Files

4

Last publish

Collaborators

  • steevepay
  • guillaume-carbone
  • dgrelaud