File tree Expand file tree Collapse file tree 1 file changed +2
-21
lines changed Expand file tree Collapse file tree 1 file changed +2
-21
lines changed Original file line number Diff line number Diff line change 1
1
import fs from 'fs'
2
2
import axios from 'axios'
3
- import axiosRetry from 'axios-retry'
4
- import chalk from 'chalk'
5
- import { Configuration , SystemsApi } from 'spacetraders-api'
6
- import RequestQueue from './axiosRequestQueue'
7
- import env from './.env.js'
3
+ import FTL from './dist'
8
4
9
- const configuration = new Configuration ( {
10
- // read token from environment variables
11
- accessToken : env . TOKEN
12
- } )
13
5
14
6
// create our axios client
15
7
const instance = axios . create ( )
16
8
// setup retry
17
- axiosRetry ( instance )
18
-
19
9
// create rate limit queue
20
- const rateLimitedAxiosQueue = new RequestQueue ( {
10
+ const rateLimitedAxiosQueue = new FTL ( {
21
11
maxRequestsPerSecond : 4 ,
22
12
burstRequests : 10 ,
23
13
burstTime : 10 ,
24
14
instance
25
15
} )
26
16
27
- // pass axios instance with rate limit queue
28
- const systems = new SystemsApi ( configuration , undefined , rateLimitedAxiosQueue . getInstance ( ) )
29
- // let currentSystem: System | null = null
30
-
31
- process . on ( 'exit' , ( ) => {
32
- const requestLogs = rateLimitedAxiosQueue . exportRequestLogs ( )
33
- fs . writeFileSync ( 'run.json' , JSON . stringify ( requestLogs , null , 2 ) ) ;
34
- } )
35
-
36
17
async function run ( ) {
37
18
for ( let i = 0 ; i < 120 ; i ++ ) {
38
19
// console.log(`Running: ${i}`)
You can’t perform that action at this time.
0 commit comments