1.0.13 • Published 5 years ago

net4j-throttle-plugin v1.0.13

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

net4j-throttle-plugin

Throttle each request in waiting time.

Only same method, url, params and data will be throttled.

import Net from 'net4j';
import NetThrottle, { ThrottleConfig } from 'net4j-throttle-plugin';

// Merge plugin config to net4j config,then you can use it in every requst in net4j
declare module 'net4j' {
  interface Config extends ThrottleConfig {}
}

const net = new Net({
  plugins: [
    new NetThrottle({
      wait: 2000, // default is 1000 ms
    }),
  ]
});

// api/goods with id=1 can only request once in 2 seconds
await net.get('api/goods', {params: {id: 1}});

// api/goods with id=2 can only request once in 2 seconds
await net.get('api/goods', {params: {id: 2}});
1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago