-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ts
31 lines (27 loc) · 865 Bytes
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import fs from 'fs'
import axios from 'axios'
import FTL from './dist'
// create our axios client
const instance = axios.create()
// setup retry
// create rate limit queue
const rateLimitedAxiosQueue = new FTL({
maxRequestsPerSecond: 4,
burstRequests: 10,
burstTime: 10,
instance
})
async function run() {
for (let i = 0; i < 120; i++) {
// console.log(`Running: ${i}`)
systems.getSystem(env.HOME_SYSTEM)
.then(res => {
// const remaining = res.headers['x-ratelimit-remaining']
// const reset = res.headers['x-ratelimit-reset']
// console.log('')
// console.log(`${i}:${res.status}: Remaining:${remaining} reset:${Math.abs(new Date(reset).getTime() - new Date().getTime())}`)
})
.catch((err: Error) => console.log(chalk.red(err.message)))
}
}
run().catch(() => console.log("The loop threw"))