Skip to content

Commit

Permalink
feat: remove axios from dependencies (#403)
Browse files Browse the repository at this point in the history
* feat: remove axios usage

* fix: remove unused import

* docs: add comment on why we use usedTcp = true
  • Loading branch information
CosminPerRam authored Nov 12, 2023
1 parent cee42e7 commit 371fad3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 166 deletions.
152 changes: 0 additions & 152 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"README.md"
],
"dependencies": {
"axios": "^1.6.1",
"cheerio": "^1.0.0-rc.12",
"gbxremote": "^0.2.1",
"got": "^13.0.0",
Expand Down
20 changes: 7 additions & 13 deletions protocols/epic.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Core from './core.js'
import axios from 'axios'

export default class Epic extends Core {
constructor () {
Expand All @@ -17,6 +16,9 @@ export default class Epic extends Core {
this.deploymentId = null
this.epicApi = 'https://api.epicgames.dev'
this.accessToken = null

// Don't use the tcp ping probing
this.usedTcp = true
}

async run (state) {
Expand All @@ -36,12 +38,9 @@ export default class Epic extends Core {
}

this.logger.debug(`POST: ${url}`)
const response = await axios.post(url, body, { headers })
if (response.status !== 200) {
throw new Error('Failed to get OAuth token')
}
const response = await this.request({ url, body, headers, method: 'POST', responseType: 'json' })

this.accessToken = response.data.access_token
this.accessToken = response.access_token
}

async queryInfo (state) {
Expand All @@ -62,18 +61,13 @@ export default class Epic extends Core {
}

this.logger.debug(`POST: ${url}`)
const response = await axios.post(url, body, { headers })
if (response.status !== 200) {
throw new Error('Failed to get server info')
}

const reader = response.data
const response = await this.request({ url, json: body, headers, method: 'POST', responseType: 'json' })

// Epic returns a list of sessions, we need to find the one with the desired port.
const hasDesiredPort = (session) => session.attributes.ADDRESSBOUND_s === `0.0.0.0:${this.options.port}` ||
session.attributes.ADDRESSBOUND_s === `${this.options.address}:${this.options.port}`

const desiredServer = reader.sessions.find(hasDesiredPort)
const desiredServer = response.sessions.find(hasDesiredPort)

if (!desiredServer) {
throw new Error('Server not found')
Expand Down

0 comments on commit 371fad3

Please sign in to comment.