npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

capsule-http

v1.1.18

Published

`yarn add capsule-http` or `npm instal capsule-http --save`

Readme

Capsule HTTP

The idea is to encapsulate the HTTP call making it easier to implement the requests by removing the need for duplicate settings. The methods are designed once all through the application and are fully accessible through the Capsule package. Another feature is that it has already been implemented with requests caching using the external "axios-extensions" package.

Install

yarn add capsule-http or npm instal capsule-http --save

To use this package is quite simple, after installed you need to import and register the requests with an url

import Capsule from 'capsule-http'

// Create a file called API.js and put your server requests there
// All of your apis will be accessible just importing the capsule-http
Capsule.register("https://your-global-endpoint", {
  get: {
    'fetch.posts': '/posts/:id',
    'fetch.post': '/post',
    'fetch.mongodb.post': '/posts/3',
  },
  post: {
    'update.posts': '/posts/:id'
  },
  put: {
    'insert.posts': '/posts/:id'
  },
  delete: {
    'remove.post': '/posts/:id'
  }
})

You can also use the register to define any object property as cache, just passing an object instead of the url:

import Capsule from 'capsule-http'

Capsule.register("https://your-global-endpoint", {
  get: {
    'fetch.posts': {
      url: '/posts/:id',
      cache: 300
    },
    'fetch.post': '/post',
    'fetch.mongodb.post': '/posts/3',
  }
})

Into your application services, import the package and execute the request

import Capsule from 'capsule-http'
Capsule.request('fetch.posts')

// 4. You can pass parameters with the request
Capsule.request('fetch.posts', { id: 3 })

You can also pass an options parameter, which you can pass info like headers, timeout, auth data or any other axios config specific

There's two configs that are not listed into axios.

  1. Caching data, this wrapper come with axios-extension cache adapter to handle cache requests, to take advantage of just pass the time in seconds of the cache as option parameter:
// If you want, you can also set a cache handler to optimize requests (ex: 10 minutes)
Capsule.request('fetch.posts', { id: 3 }, { cache: 600 })

The default it's configured as 5 minutes but you can pass any time that you wish

You can make a request without cache, this way the cache keeps working but your request answer without it

Capsule.request('fetch.posts', { id: 3 }, { cache: false })

You can also force the cache to be cleaned using a flag forceUpdate to remove it or updated it's ttl

Capsule.request('fetch.posts', { id: 3 }, { forceUpdate: true, cache: false })
// or
Capsule.request('fetch.posts', { id: 3 }, { forceUpdate: true, cache: 500 })

Testing

Just run yarn test or npm run test and the command line will start a local server wich will be test every single route and parameters related to the js API.

Improvements

The package 'axios-extesions' provides also an throttleAdapterEnhancer designed to help multiples requests return same data without any aditional check, just returning the same response did in the last second.

This adapter wasn't implemented yet because need extensive tests related on how it would perform in a node server to handle not just client side requests but also backend requests.