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

algo-network-manager

v1.1.13

Published

[![GitHub Repository](https://img.shields.io/badge/GitHub-algo--network-blue?logo=github)](https://github.com/necipsunbul/algo-network) [![TypeScript](https://img.shields.io/badge/TypeScript-100%25-blue?logo=typescript)](https://github.com/necipsunbul/alg

Downloads

36

Readme

Algo Network Manager

GitHub Repository TypeScript License: ISC

A modern and flexible TypeScript library for HTTP client management. Simplifies request/response handling with interceptor support.

Installation

npm install algo-network-manager

Basic Usage

import createAlgoInstance, { HttpClient } from "algo-network-manager";

const client = createAlgoInstance(
  new HttpClient({
    baseURL: "http://google.com.tr",
  })
);

client.get("/").then((payload) => console.log(payload));

Key Features

  • 🚀 TypeScript support
  • 🔧 Interceptor system
  • 🌐 Flexible HTTP client configuration
  • 📦 Reliable network operations based on Axios
  • 🔌 Easy integration

API Usage

createAlgoInstance(httpClient, interceptors?)

The main function createAlgoInstance is used to create and return a NetworkManager instance.

Parameters:

  • httpClient: Client that implements the IHttpClient interface (HttpClient)
  • interceptors: (Optional) Array of IInterceptor

Return Value: NetworkManager instance with the following methods:

  • get(url, config?)
  • post(url, data?, config?)
  • put(url, data?, config?)
  • delete(url, config?)
  • patch(url, data?, config?)

Interceptor Usage

Interceptors are used to intercept request and response operations.

Example Auth Interceptor

import { type IInterceptor } from "algo-network-manager";

export class AuthInterceptor implements IInterceptor {
  constructor() {}

  onRequest(config: any): any {
    const token = localStorage.getItem("your_token_title");
    if (token) {
      config.headers = {
        ...config.headers,
        Authorization: `Bearer ${token}`,
      };
    }
    return config;
  }

  onRequestError(error: any): any {
    return Promise.reject(error);
  }
}

Creating Client with Interceptor

import createAlgoInstance, { HttpClient } from "algo-network-manager";

const authInterceptor = new AuthInterceptor(authService);

const client = createAlgoInstance(
  new HttpClient({
    baseURL: "https://api.example.com",
    timeout: 10000,
  }),
  [authInterceptor]
);

// Usage
client.get("/users").then((response) => {
  console.log(response);
});

client
  .post("/users", {
    name: "John Doe",
    email: "[email protected]",
  })
  .then((response) => {
    console.log("User created:", response);
  });

HttpClient Configuration

const httpClient = new HttpClient({
  baseURL: "https://api.example.com",
  timeout: 5000,
  headers: {
    "Content-Type": "application/json",
  },
  validateStatus: (status: number) => status >= 200 && status < 300,
});

Configuration Options

  • baseURL: Base URL for all requests

  • timeout: Request timeout in milliseconds (default: 10000)

  • headers: Default headers to be sent with every request

  • validateStatus: Function to determine if HTTP status code should be considered successful

    • Type: (status: number) => boolean

    • Default: undefined (uses Axios default: 200-299 range)

    • Example:

      // Accept only 200 status as successful
      validateStatus: (status) => status === 200;
      
      // Accept 200-399 range as successful
      validateStatus: (status) => status >= 200 && status < 400;

Advanced Usage

Multiple Interceptors

const loggingInterceptor = new LoggingInterceptor();
const authInterceptor = new AuthInterceptor(authService);
const errorHandlerInterceptor = new ErrorHandlerInterceptor();

const client = createAlgoInstance(
  new HttpClient({ baseURL: "https://api.example.com" }),
  [loggingInterceptor, authInterceptor, errorHandlerInterceptor]
);

Error Handling

client
  .get("/api/data")
  .then((response) => {
    console.log("Success:", response);
  })
  .catch((error) => {
    console.error("Request failed:", error);
  });

Interfaces

IInterceptor

interface IInterceptor {
  onRequest?(config: any): any;
  onRequestError?(error: any): any;
  onResponse?(response: any): any;
  onResponseError?(error: any): any;
}

IHttpClient

interface IHttpClient {
  get<T>(url: string, config?: any): Promise<T>;
  post<T>(url: string, data?: any, config?: any): Promise<T>;
  put<T>(url: string, data?: any, config?: any): Promise<T>;
  delete<T>(url: string, config?: any): Promise<T>;
  patch<T>(url: string, data?: any, config?: any): Promise<T>;
  request<T>(config: any): Promise<T>;
}

License

ISC

Repository

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please make sure to update tests as appropriate and follow the existing code style.

Development

# Clone the repository
git clone https://github.com/necipsunbul/algo-network.git

# Install dependencies
npm install

# Build the project
npm run build

# Run tests
npm test