Skip to content

Commit f3ab178

Browse files
committed
fix:removed node-fetch and updated node version dependencies
Signed-off-by: Amitkanswal <[email protected]>
1 parent 1523b08 commit f3ab178

File tree

9 files changed

+22
-9571
lines changed

9 files changed

+22
-9571
lines changed

.eslintrc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212
"plugin:@typescript-eslint/eslint-recommended",
1313
"plugin:@typescript-eslint/recommended"
1414
],
15-
"env": {
16-
"browser": true,
17-
"node": true
18-
},
19-
2015
"rules": {
2116
"@typescript-eslint/no-explicit-any": 0,
2217
"@typescript-eslint/prefer-const": 0,

.github/workflows/node.js.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
strategy:
1818
matrix:
19-
node-version: [12.x]
19+
node-version: [18.x]
2020
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
2121

2222
steps:

.github/workflows/npm-publish-github-packages.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/checkout@v3
1515
- uses: actions/setup-node@v3
1616
with:
17-
node-version: 14
17+
node-version: 18
1818
- run: npm ci
1919
- run: npm test
2020

@@ -28,7 +28,7 @@ jobs:
2828
- uses: actions/checkout@v3
2929
- uses: actions/setup-node@v3
3030
with:
31-
node-version: 14
31+
node-version: 18
3232
registry-url: https://npm.pkg.github.com/
3333
- run: npm ci
3434
- run: npm publish

.github/workflows/npm-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/checkout@v2
1515
- uses: actions/setup-node@v2
1616
with:
17-
node-version: 16
17+
node-version: 18
1818
- run: npm ci
1919
- run: npm test
2020

@@ -25,7 +25,7 @@ jobs:
2525
- uses: actions/checkout@v2
2626
- uses: actions/setup-node@v2
2727
with:
28-
node-version: 16
28+
node-version: 18
2929
registry-url: https://registry.npmjs.org/
3030
- run: npm ci
3131
- run: npm publish

.github/workflows/unit-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ jobs:
1616

1717
strategy:
1818
matrix:
19-
node-version: [14.x]
19+
node-version: [18.x]
2020

2121
steps:
2222
- name: Checkout repository
2323
uses: actions/checkout@v2
2424
with:
25-
node-version: '14.x'
25+
node-version: '18.x'
2626

2727
- name: Use Node.js
2828
uses: actions/setup-node@v2
2929
with:
30-
node-version: '14.x'
30+
node-version: '18.x'
3131

3232
- name: Install deps
3333
run: npm ci

package-lock.json

Lines changed: 4 additions & 9535 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,8 @@
7373
"npm run prettier:fix ",
7474
"npm run lint:fix"
7575
]
76+
},
77+
"engines": {
78+
"node": ">=18.x"
7679
}
77-
}
80+
}

src/utils/adapter.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import PostRobot from "post-robot";
2-
import { Response } from "node-fetch";
32
import {
43
AxiosError,
54
AxiosHeaders,
@@ -50,11 +49,6 @@ export const dispatchAdapter =
5049
});
5150
};
5251
/**
53-
GitHub Copilot
54-
To handle errors generically and robustly, we can refactor the code to ensure that all errors are properly processed and converted into a standardized format. Here's how you can fix and improve the error handling in the provided code:
55-
56-
Refactored Code
57-
5852
* Dispatches an API request using axios and PostRobot.
5953
* @param url - The URL of the API endpoint.
6054
* @param options - Optional request options.
@@ -73,23 +67,21 @@ export const dispatchApiRequest = async (
7367
return new Response(response?.data, {
7468
status: response.status,
7569
statusText: response.statusText,
76-
url: response.config.url,
77-
headers: new Headers(Object.entries(response.headers ?? {})),
70+
headers: response.config.headers,
7871
});
7972
} catch (err: any) {
8073
if (err.response) {
8174
return new Response(err.response?.data, {
82-
status: err.status,
83-
statusText: err.statusText,
84-
headers: new Headers(
85-
Object.entries(err.response.headers ?? {})
86-
),
75+
status: err.response.status,
76+
statusText: err.response.statusText,
77+
headers: err.response.headers
78+
8779
});
8880
}
8981
return new Response(err.stack, {
9082
status: err.status || 500,
9183
statusText: err.message || "Internal Server Error",
92-
headers: new Headers(Object.entries(err.headers ?? {})),
84+
headers: err.config.headers,
9385
});
9486
}
9587
};

src/utils/utils.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@ export function onError(error: Error) {
1313
return Promise.reject(error);
1414
}
1515

16-
export function sanitizeResponseHeader(axiosHeaders) {
17-
const fetchHeaders = new Headers();
18-
for (const key in axiosHeaders) {
19-
fetchHeaders.append(key, axiosHeaders[key]);
20-
}
21-
return fetchHeaders;
22-
}
23-
2416
export function formatAppRegion(region: string): RegionType {
2517
return region ?? Region.UNKNOWN;
2618
}

0 commit comments

Comments
 (0)