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

@cabysis/candy-client

v1.0.5

Published

HTTP Client for making request with native fetch library

Readme

HTTP Client

Make HTTP Requests in a pretty easy way! Configure all your microservices endpoints in different modules and send requests!

Usage

You can use this library after installation as this example:

import { CandyClient, CandyClientOptions } from "./client";

// Example static function to retrieve a JWT token
// This function simulates retrieving a token for authorization purposes.
function getToken(): string {
  return "generic-jwt-token"; // Replace with actual logic to retrieve JWT token dynamically.
}

// Shared configuration options for CandyClient
// These options are applied to all client instances by default.
const sharedOptions: CandyClientOptions = {
  baseUrl: "http://localhost:8080/", // Base URL for the API endpoints
  headers: {
    Accept: "application/json", // Indicate that JSON is expected in responses
    "Content-Type": "application/json", // Specify that JSON is sent in requests
    "Access-Control-Allow-Origin": "*", // Allow cross-origin requests (CORS)
  },
  getToken: getToken, // Reference to the function that retrieves the JWT token
};

// Representation of a User entity
// Defines the structure of user data expected from the API.
class User {
  id: number; // Unique identifier for the user
  name: string; // Name of the user
  email: string; // Email address of the user
}

// Example client class for interacting with the authentication service
// Extends the generic CandyClient to include specific auth-related methods.
class AuthClient extends CandyClient {
  constructor() {
    super(sharedOptions); // Initialize the client with shared configuration options
  }

  // Method to sign in a user using email and password
  // Sends a POST request to the /auth/sign-in endpoint.
  async signIn(email: string, password: string): Promise<void> {
    return this.post<void>("/auth/sign-in", { email, password });
  }

  // Method to retrieve a list of all users
  // Sends a GET request to the /auth/users endpoint and returns a list of User objects.
  async getUsers(): Promise<User[]> {
    return this.get<User[]>("/auth/users");
  }

  // Method to retrieve credentials with custom headers
  // Sends a GET request to the /auth/credentials endpoint and overrides default headers.
  async getCredentials(): Promise<{ password: string; token: string }> {
    return this.get<{ password: string; token: string }>("/auth/credentials", {
      headers: {
        Authorization: "<Custom credential>", // Example of a custom Authorization header
        "Content-Type": "application/json",
      },
    });
  }

  // Method to upload a profile photo using multipart form data
  // Sends a POST request to the /auth/profile/photo endpoint with a file in FormData format.
  async uploadProfilePhoto(file: File): Promise<void> {
    const formData = new FormData();
    formData.append("file", file); // Append the file to the FormData object
    return this.post<void>("/auth/profile/photo", formData, {
      isMultipart: true, // Flag to indicate multipart form data is being used
    });
  }

  // Method to retrieve a profile photo as a Blob object
  // Sends a GET request to the /auth/profile/photo endpoint with Blob parsing enabled.
  async getProfilePhoto(): Promise<Blob> {
    return this.get<Blob>("/auth/profile/photo", {
      parseBlob: true, // Flag to parse the response as a Blob
    });
  }

  // Method to retrieve raw profile data as a Response object
  // Sends a GET request to the /auth/profile endpoint without parsing the response.
  async getProfileData(): Promise<Response> {
    return this.get<Response>("/auth/profile", {
      parseResponse: false, // Flag to return the raw response object
    });
  }
}

// Example use case for the sign-in request
// Demonstrates how to use the AuthClient to sign in a user.
async function signIn(email: string, password: string): Promise<void> {
  try {
    const authClient = new AuthClient(); // Create an instance of the AuthClient
    await authClient.signIn(email, password); // Attempt to sign in with the provided credentials
    console.log("Sign-in successful"); // Log success message if sign-in is successful
  } catch (error) {
    console.error("Sign-in failed:", error); // Log an error message if sign-in fails
  }
}