@kronos-integration/interceptor
TypeScript icon, indicating that this package has built-in type declarations

10.3.1 • Public • Published

License Typed with TypeScript GitHub Issues Build Status Styled with prettier Commitizen friendly Known Vulnerabilities Coverage Status

@kronos-integration/interceptor

intercepects / modifies requests as they pass between endpoints

const { Interceptor } from '@kronos-integration/interceptor';

const endpoint = { get name() { return 'aName'; }, receive() {}};
const interceptor = new Interceptor();

const response = interceptor.receive(endpoint, arg1, arg2);

API

Table of Contents

Endpoint

Type: Object

Interceptor

Base interceptor. The base class for all the interceptors Calls configure() and reset().

Parameters

  • config Object The interceptor configuration object.

type

The instance method returning the type. Defaults to the constructors name (class name)

Returns string

configurationAttributes

Meta description of the configuration.

Returns Object

configure

Takes attribute values from config parameters and copies them over to the object. Copying is done according to configurationAttributes. Which means we loop over all configuration attributes and then for each attribute decide if we use the default, call a setter function or simply assign the attribute value.

Parameters

toJSONWithOptions

Deliver the json representation.

Parameters

  • options

Returns Object json representation

reset

Forget all accumulated information.

receive

The receive method. This method receives the request from the leading interceptor and calls the trailing interceptor.

Parameters

Returns Promise<any>

configurationAttributes

Meta description of the configuration

Returns Object

LimitingInterceptor

Extends Interceptor

Limits the number of concurrent requests. Requests can be delayed or rejected. Sample config: [ { count: 20 }, { count: 10, delay: 100 }, { count: 5, delay: 10 } ] 1 - 4 : no delay 5 - 9 : 10ms delay 10 - 19 : 100ms delay 20 : reject default is to reject when more than 10 requests are on the way

Parameters

  • config

name

Returns string 'request-limit'

LoggingInterceptor

Extends Interceptor

logs args and result

name

Returns string 'logging'

StatsCollectorInterceptor

Extends Interceptor

Interceptor to collect processing time, number of processed and failed requests.

receive

Logs the time the requests takes

Parameters

  • endpoint
  • args ...any

name

Returns string 'collect-request-stats'

TemplateInterceptor

Extends Interceptor

Map params into requests.

name

Returns string 'template'

TimeoutInterceptor

Extends Interceptor

Rejects a request if it does not resolve in a given time.

Properties

name

Returns string 'timeout'

rejectUnlessResolvedWithin

Rejects promise when it is not resolved within given timeout.

Parameters

Returns Promise<any>

expand

Expands '{{exp}}' expressions.

Parameters

Returns any expanded value

install

With npm do:

npm install @kronos-integration/interceptor

license

BSD-2-Clause

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
10.3.1
448latest

Version History

VersionDownloads (Last 7 Days)Published
10.3.1
448
10.3.0
293
10.2.38
0
10.2.370
10.2.360
10.2.350
10.2.340
10.2.330
10.2.320
10.2.310
10.2.301
10.2.290
10.2.280
10.2.270
10.2.260
10.2.250
10.2.240
10.2.230
10.2.220
10.2.210
10.2.200
10.2.190
10.2.180
10.2.170
10.2.160
10.2.150
10.2.140
10.2.130
10.2.120
10.2.110
10.2.100
10.2.90
10.2.80
10.2.70
10.2.60
10.2.50
10.2.40
10.2.30
10.2.20
10.2.10
10.2.00
10.1.00
10.0.130
10.0.120
10.0.110
10.0.100
10.0.90
10.0.81
10.0.70
10.0.60
10.0.50
10.0.40
10.0.30
10.0.20
10.0.10
10.0.00
9.2.20
9.2.10
9.2.00
9.1.00
9.0.00
8.1.61
8.1.50
8.1.40
8.1.30
8.1.20
8.1.10
8.1.00
8.0.20
8.0.10
8.0.00
7.0.00
6.1.30
6.1.20
6.1.11
6.1.01
6.0.00
5.0.00
4.0.10
4.0.00

Package Sidebar

Install

npm i @kronos-integration/interceptor

Weekly Downloads

746

Version

10.3.1

License

BSD-2-Clause

Unpacked Size

25.8 kB

Total Files

19

Last publish

Collaborators

  • arlac77
  • darlenya