From 6eebc309bc3f7cbe9d3c8cf2a52983e2f64cd51e Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Wed, 21 Feb 2024 08:37:36 +0100 Subject: [PATCH] fix: remove more interceptor stuff --- index.js | 3 +-- lib/interceptor/redirectInterceptor.js | 21 --------------------- types/interceptors.d.ts | 5 ----- 3 files changed, 1 insertion(+), 28 deletions(-) delete mode 100644 lib/interceptor/redirectInterceptor.js delete mode 100644 types/interceptors.d.ts diff --git a/index.js b/index.js index bf46fc08d98..e6d3b6f4656 100644 --- a/index.js +++ b/index.js @@ -19,7 +19,6 @@ const RetryHandler = require('./lib/handler/RetryHandler') const { getGlobalDispatcher, setGlobalDispatcher } = require('./lib/global') const DecoratorHandler = require('./lib/handler/DecoratorHandler') const RedirectHandler = require('./lib/handler/RedirectHandler') -const createRedirectInterceptor = require('./lib/interceptor/redirectInterceptor') Object.assign(Dispatcher.prototype, api) @@ -33,7 +32,7 @@ module.exports.RetryHandler = RetryHandler module.exports.DecoratorHandler = DecoratorHandler module.exports.RedirectHandler = RedirectHandler -module.exports.createRedirectInterceptor = createRedirectInterceptor + module.exports.buildConnector = buildConnector module.exports.errors = errors diff --git a/lib/interceptor/redirectInterceptor.js b/lib/interceptor/redirectInterceptor.js deleted file mode 100644 index 7cc035e096c..00000000000 --- a/lib/interceptor/redirectInterceptor.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict' - -const RedirectHandler = require('../handler/RedirectHandler') - -function createRedirectInterceptor ({ maxRedirections: defaultMaxRedirections }) { - return (dispatch) => { - return function Intercept (opts, handler) { - const { maxRedirections = defaultMaxRedirections } = opts - - if (!maxRedirections) { - return dispatch(opts, handler) - } - - const redirectHandler = new RedirectHandler(dispatch, maxRedirections, opts, handler) - opts = { ...opts, maxRedirections: 0 } // Stop sub dispatcher from also redirecting. - return dispatch(opts, redirectHandler) - } - } -} - -module.exports = createRedirectInterceptor diff --git a/types/interceptors.d.ts b/types/interceptors.d.ts deleted file mode 100644 index 047ac175d50..00000000000 --- a/types/interceptors.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import Dispatcher from "./dispatcher"; - -type RedirectInterceptorOpts = { maxRedirections?: number } - -export declare function createRedirectInterceptor (opts: RedirectInterceptorOpts): Dispatcher.DispatchInterceptor