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 🙏

© 2024 – Pkg Stats / Ryan Hefner

osham

v1.0.2

Published

A Configuration based Proxy server to cache API response.

Downloads

3

Readme

ओषम् (Osham)

Total alerts Language grade: JavaScript

A Configurable Proxy Cache Server.

npx osham
 npm i -g osham
 npm i osham

What is ओषम् (Osham) ?

Osham is a cache service for APIs.

The idea behind Osham is to support higher concurrent requests with fewer resources and fast response time.

In a public facing API/frontend, most of the request remains the same and so the response is also the same. To avoid rendering the same request from the backend and to speed up the response time we should use CACHE.

The cache can solve many problems and it uses fewer backend resources to provide a good response time.

But that's not it.

In a real-world scenario, what happens when your backend is requested with hundreds of concurrent requests for the first time. In all those concurrent requests, there will be cache miss and will cause a thundering herd problem.

All of these problems and many more can be resolved by using Osham in your architecture.

Setup and Configure

  • Create a folder.
    mkdir cache
  • Move in this newly created folder
    cd cache
  • Install osham using

    npm install osham

    OR

    npm install osham -g
  • Create a .env file.

    touch .env
  • Configure and place following in the .env file.

    # Port number on the cache server will listen to incoming requests
    PORT=26192
    # Redis host name
    REDIS_HOST=localhost
    # Redis port number
    REDIS_PORT=6379
    # HTTPS Options
    SECURE=false
    SSL_KEY=
    SSL_CERT=
    # Timeout for cache service. Default is 5000 ms
    TIMEOUT=7000
  • Now, just need to create a cache-config.yml file. To get started copy file from here.

  • Run osham as If you have installed it using -g flag, you will be able to run it directly from cmd.

    osham

    Or

    ./node_module/.bin/osham

    Or using package.json add into scripts of package.json as "start": "osham"

    npm start
  • Open http://localhost:26192/api/v1/employees in the browser. Cache Server will hit the http://dummy.restapiexample.com/api/v1/employees . It will cache the result for the next 5 minutes as per over about cache configuration.

Cache Options

  • expose The proxy path which will expose from osham.

  • target The actual server HOST name (with path).

  • changeOrigin: The actual request's HOST name will be passed to backend.

  • followRedirects The HTTP/HTTPS agent will be changes to follow redirects if server has internal redirection enabled.

  • timeout Default 5000 miliseconds.

Use Cases

You are a frontend developer and you don't want to set up backend on your machine, but want a faster development experience.

To reduce TTFB on google page insights in the production environment.

To support a large number of requests with fewer resources.

Centralized many servers end-points to one.

Limitations

  1. It only supports anonymous requests.
  2. It will only cache GET requests.
  3. In Node Cluster, Requests will be pooled and served from the single response of backend per cache thread.

Architecture

Osham Archtecture

Osham Auth Arch

More Optimized Osham

Osham master slave