Skip to content

Commit

Permalink
Replace axios library with built-in fetch
Browse files Browse the repository at this point in the history
Signed-off-by: David Thompson <[email protected]>
  • Loading branch information
datho7561 authored and angelozerr committed Aug 21, 2024
1 parent 90d6da3 commit 0fa1c0e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
1 change: 0 additions & 1 deletion 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 @@ -456,7 +456,6 @@
"@types/yauzl": "^2.10.3",
"@typescript-eslint/eslint-plugin": "^8.0.1",
"@typescript-eslint/parser": "^8.0.1",
"axios": "^1.6.7",
"chai": "^4.5.0",
"chai-fs": "^2.0.0",
"eslint": "^8.57.0",
Expand Down
19 changes: 10 additions & 9 deletions src/utils/requestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

import axios from 'axios';
import * as fs from 'fs';
import * as p from 'path';
import { Readable } from 'stream';
Expand All @@ -41,12 +40,15 @@ export async function getQExtensions(platform?: string): Promise<QExtension[]> {

async function tryGetExtensionsJSON(apiUrl: string): Promise<APIExtension[]> {
try {
const response = await axios.get(apiUrl, {
const abortController = new AbortController();
const timeout = setTimeout(() => { abortController.abort(); }, 30_000);
const response = await fetch(apiUrl, {
headers: HEADERS,
timeout: 30_000,
signal: abortController.signal
});
return response.data;
} catch (_err) {
clearTimeout(timeout);
return (await response.json()) as APIExtension[];
} catch {
throw `Unable to reach ${apiUrl}`;
}
}
Expand Down Expand Up @@ -87,12 +89,11 @@ export async function downloadProject(state: ProjectGenState, codeQuarkusFunctio

async function tryGetProjectBuffer(projectUrl: string): Promise<Buffer> {
try {
const response = await axios.get(projectUrl, {
const response = await fetch(projectUrl, {
headers: HEADERS,
responseType: 'arraybuffer',
});
return response.data as Buffer;
} catch (_err) {
return Buffer.from(await response.arrayBuffer());
} catch {
throw 'Unable to download Quarkus project.';
}
}
Expand Down

0 comments on commit 0fa1c0e

Please sign in to comment.