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

sarvis

v0.0.15

Published

A simple, small api that helps organise and execute your HTTP requests with excellent Typescript support. build on top of the browser native fetch api.

Downloads

11

Readme

Sarvis

Sarvis is a simple, small api that helps organise and execute your HTTP requests with excellent Typescript support. build on top of the browser native fetch api.

Using Sarvis

To create a new instance of Sarvis:

const sarvis = new Sarvis();

It's possible to pass a base configuration to Sarvis:

const sarvis = new Sarvis({
    // The url that will be used in every request.
    base_url: "https://www.your-domain.com",
    // (Optional) The port number that will be used for a request.
    port: 3000,
    // (Optional) Most api's have a base path, such as: /api, or /v1 etc.
    base_path: "/api",
    // (Optional) A string that will be set to the Authorazation header on every request, for example:
    // "Bearer YOUR_BEARER_TOKEN_HERE".
    authorization: "Bearer a_token_here"
});

// You can access and update the configuration through sarvis.config:
const config: ISarvisConfig = sarvis.config;

// Let's update the authorization for example:
sarvis.config.authorization = "Bearer a_token_here";

Requests

GET

Let's say we're fetching a TODO item that looks like this:

{
  "id": 1,
  "todo": "Clean Kitchen" 
}

And we have an Interface declared for this dto:

interface TodoDto {
    id: number;
    todo: string;
}

Let's perform a GET request for that Todo:

const result = await sarvis.get<TodoDto>("https://www.your-domain.com/api/1");

Your result object is now of type TodoDto.

If you have added a config with base_url, you only need to add the part that comes after:

const result = await sarvis.get("/1");

POST, PUT, DELETE

For all other requests, add a body after the URL:

const postResult = await sarvis.post<TodoDto>("/1", body);

const putResult = await sarvis.put<TodoDto>("/1", body);

// The body for a DELETE request is optional.
const deleteResult = await sarvis.post<boolean>("/1", body);

Custom Configuration

You won't of course, always want to use the standard request configuration. It's possible to add a custom configuration to every request:

const customConfig: RequestInit = {
    method: "POST",
}
const result = await sarvis.get("/1", customConfig);

useBefore and useAfter

Sometimes you want to execute an operation before, or after evey request. Sarvis offers an easy way to do so:

// Executed before every request.
sarvis.useBefore = (url: string, config: RequestInit) => {
    url = url + "/todos";
    config.headers.append("Content-Type", "blob");
    
    return { url, config };
};

// Executed after every request, if returnFullRequest is set to true, it will return the full Request object.
sarvis.useAfter = (result: any) => {
    result["newValue"] = "Some Test value for demo purposes.";

    return result;
};

Get the Request before JSON conversion

By default, request results are converted to JSON and then given back to the user. Of course not all request have a return type of JSON, or perhaps you want to have a look at the complete response.

To turn off JSON conversion for all Requests, set:

sarvis.returnFullRequest = true;

Every request will now return the complete response.