Skip to content

Commit 1936d73

Browse files
committed
adapt test file to FTL package
1 parent 28aecb1 commit 1936d73

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

test.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,19 @@
11
import fs from 'fs'
22
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'
84

9-
const configuration = new Configuration({
10-
// read token from environment variables
11-
accessToken: env.TOKEN
12-
})
135

146
// create our axios client
157
const instance = axios.create()
168
// setup retry
17-
axiosRetry(instance)
18-
199
// create rate limit queue
20-
const rateLimitedAxiosQueue = new RequestQueue({
10+
const rateLimitedAxiosQueue = new FTL({
2111
maxRequestsPerSecond: 4,
2212
burstRequests: 10,
2313
burstTime: 10,
2414
instance
2515
})
2616

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-
3617
async function run() {
3718
for (let i = 0; i < 120; i++) {
3819
// console.log(`Running: ${i}`)

0 commit comments

Comments
 (0)