New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

interceptor-builder

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

interceptor-builder

A modern collection of reusable utility functions for JavaScript and TypeScript, designed to simplify everyday development tasks.

Source
npmnpm
Version
1.3.0
Version published
Weekly downloads
7
-46.15%
Maintainers
1
Weekly downloads
 
Created
Source

Interceptor Builder

A clean and extendable interceptor builder for chaining and organizing multiple request/response interceptors.

📦 Installation

npm install interceptor-builder

🚀 Getting Started

#1. Create Custom Interceptors

import type { Interceptor, Req, Res, Instance } from "interceptor-builder";

export default class MyInterceptor implements Interceptor {
   public instance: Instance;

   constructor(instance: Instance) {
      this.instance = instance;
   }

   intercept(req: Req, res: Res): Instance {
      req.use(
         (config) => config,
         (error) => Promise.reject(error)
      );

      res.use(
         (response) => response,
         (error) => Promise.reject(error)
      );

      return this.instance;
   }
}

#2. Interceptor builder

import InterceptorBuilder from "interceptor-builder";
import MyInterceptor from "...";

const axiosInstance = axios.create();
return new InterceptorBuilder(this.instance) //
   .use(MyInterceptor)
   .build();

📄 License

This package is open-source and available under the MIT License.

Keywords

javasript

FAQs

Package last updated on 15 Jul 2025

Related posts