1.0.13 • Published 6 years ago

net4j-throttle-plugin v1.0.13

Weekly downloads
-
License
MIT
Repository
-
Last release
6 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

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago