Merged in feat/sw-3623-fetchretry (pull request #3180)
feat(SW_3623): remove fetch-retry * feat(SW_3623): remove fetch-retry Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import merge from "deepmerge"
|
import merge from "deepmerge"
|
||||||
import fetchRetry from "fetch-retry"
|
|
||||||
|
|
||||||
import { env } from "../../env/server"
|
import { env } from "../../env/server"
|
||||||
|
|
||||||
@@ -24,13 +23,6 @@ const defaultOptions: RequestInit = {
|
|||||||
mode: "cors",
|
mode: "cors",
|
||||||
}
|
}
|
||||||
|
|
||||||
const wrappedFetch = fetchRetry(fetch, {
|
|
||||||
retries: 2,
|
|
||||||
retryDelay: function (attempt) {
|
|
||||||
return Math.pow(2, attempt) * 150 // 150, 300, 600
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
export async function get(
|
export async function get(
|
||||||
endpoint: Endpoint,
|
endpoint: Endpoint,
|
||||||
options: RequestOptionsWithOutBody,
|
options: RequestOptionsWithOutBody,
|
||||||
@@ -40,7 +32,7 @@ export async function get(
|
|||||||
url.pathname = endpoint
|
url.pathname = endpoint
|
||||||
url.search = new URLSearchParams(params).toString()
|
url.search = new URLSearchParams(params).toString()
|
||||||
|
|
||||||
return wrappedFetch(url, {
|
return fetch(url, {
|
||||||
...merge.all([defaultOptions, { method: "GET" }, options]),
|
...merge.all([defaultOptions, { method: "GET" }, options]),
|
||||||
signal: AbortSignal.timeout(15_000),
|
signal: AbortSignal.timeout(15_000),
|
||||||
})
|
})
|
||||||
@@ -55,7 +47,7 @@ export async function patch(
|
|||||||
const url = new URL(env.API_BASEURL)
|
const url = new URL(env.API_BASEURL)
|
||||||
url.pathname = endpoint
|
url.pathname = endpoint
|
||||||
url.search = new URLSearchParams(params).toString()
|
url.search = new URLSearchParams(params).toString()
|
||||||
return wrappedFetch(url, {
|
return fetch(url, {
|
||||||
...merge.all([
|
...merge.all([
|
||||||
defaultOptions,
|
defaultOptions,
|
||||||
{ body: JSON.stringify(body), method: "PATCH" },
|
{ body: JSON.stringify(body), method: "PATCH" },
|
||||||
@@ -74,7 +66,7 @@ export async function post(
|
|||||||
const url = new URL(env.API_BASEURL)
|
const url = new URL(env.API_BASEURL)
|
||||||
url.pathname = endpoint
|
url.pathname = endpoint
|
||||||
url.search = new URLSearchParams(params).toString()
|
url.search = new URLSearchParams(params).toString()
|
||||||
return wrappedFetch(url, {
|
return fetch(url, {
|
||||||
...merge.all([
|
...merge.all([
|
||||||
defaultOptions,
|
defaultOptions,
|
||||||
{ body: JSON.stringify(body), method: "POST" },
|
{ body: JSON.stringify(body), method: "POST" },
|
||||||
@@ -93,7 +85,7 @@ export async function put(
|
|||||||
const url = new URL(env.API_BASEURL)
|
const url = new URL(env.API_BASEURL)
|
||||||
url.pathname = endpoint
|
url.pathname = endpoint
|
||||||
url.search = new URLSearchParams(params).toString()
|
url.search = new URLSearchParams(params).toString()
|
||||||
return wrappedFetch(url, {
|
return fetch(url, {
|
||||||
...merge.all([
|
...merge.all([
|
||||||
defaultOptions,
|
defaultOptions,
|
||||||
{ body: JSON.stringify(body), method: "PUT" },
|
{ body: JSON.stringify(body), method: "PUT" },
|
||||||
@@ -112,7 +104,7 @@ export async function remove(
|
|||||||
const url = new URL(env.API_BASEURL)
|
const url = new URL(env.API_BASEURL)
|
||||||
url.pathname = endpoint
|
url.pathname = endpoint
|
||||||
url.search = new URLSearchParams(params).toString()
|
url.search = new URLSearchParams(params).toString()
|
||||||
return wrappedFetch(url, {
|
return fetch(url, {
|
||||||
...merge.all([
|
...merge.all([
|
||||||
defaultOptions,
|
defaultOptions,
|
||||||
{ body: JSON.stringify(body), method: "DELETE" },
|
{ body: JSON.stringify(body), method: "DELETE" },
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import fetchRetry from "fetch-retry"
|
|
||||||
import { type DocumentNode, print } from "graphql"
|
import { type DocumentNode, print } from "graphql"
|
||||||
import { GraphQLClient } from "graphql-request"
|
import { GraphQLClient } from "graphql-request"
|
||||||
import stringify from "json-stable-stringify-without-jsonify"
|
import stringify from "json-stable-stringify-without-jsonify"
|
||||||
@@ -77,13 +76,7 @@ function internalRequest<T>(
|
|||||||
url: URL | RequestInfo,
|
url: URL | RequestInfo,
|
||||||
params?: RequestInit
|
params?: RequestInit
|
||||||
) {
|
) {
|
||||||
const wrappedFetch = fetchRetry(fetch, {
|
return fetch(url, {
|
||||||
retries: 2,
|
|
||||||
retryDelay: function (attempt) {
|
|
||||||
return Math.pow(2, attempt) * 150 // 150, 300, 600
|
|
||||||
},
|
|
||||||
})
|
|
||||||
return wrappedFetch(url, {
|
|
||||||
...params,
|
...params,
|
||||||
signal: AbortSignal.timeout(15_000),
|
signal: AbortSignal.timeout(15_000),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -53,7 +53,6 @@
|
|||||||
"@trpc/server": "^11.1.2",
|
"@trpc/server": "^11.1.2",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"deepmerge": "^4.3.1",
|
"deepmerge": "^4.3.1",
|
||||||
"fetch-retry": "^6.0.0",
|
|
||||||
"fuse.js": "^7.1.0",
|
"fuse.js": "^7.1.0",
|
||||||
"graphql": "^16.11.0",
|
"graphql": "^16.11.0",
|
||||||
"graphql-request": "^7.1.2",
|
"graphql-request": "^7.1.2",
|
||||||
|
|||||||
@@ -5472,7 +5472,6 @@ __metadata:
|
|||||||
eslint: "npm:^9"
|
eslint: "npm:^9"
|
||||||
eslint-plugin-import: "npm:^2.31.0"
|
eslint-plugin-import: "npm:^2.31.0"
|
||||||
eslint-plugin-simple-import-sort: "npm:^12.1.1"
|
eslint-plugin-simple-import-sort: "npm:^12.1.1"
|
||||||
fetch-retry: "npm:^6.0.0"
|
|
||||||
fuse.js: "npm:^7.1.0"
|
fuse.js: "npm:^7.1.0"
|
||||||
graphql: "npm:^16.11.0"
|
graphql: "npm:^16.11.0"
|
||||||
graphql-request: "npm:^7.1.2"
|
graphql-request: "npm:^7.1.2"
|
||||||
@@ -9892,13 +9891,6 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"fetch-retry@npm:^6.0.0":
|
|
||||||
version: 6.0.0
|
|
||||||
resolution: "fetch-retry@npm:6.0.0"
|
|
||||||
checksum: 10c0/8e275b042ff98041236d30b71966f24c34ff19f957bb0f00e664754bd63d0dfb5122d091e7d5bca21f6370d88a1713d22421b33471305d7b86d6799427278802
|
|
||||||
languageName: node
|
|
||||||
linkType: hard
|
|
||||||
|
|
||||||
"file-entry-cache@npm:^8.0.0":
|
"file-entry-cache@npm:^8.0.0":
|
||||||
version: 8.0.0
|
version: 8.0.0
|
||||||
resolution: "file-entry-cache@npm:8.0.0"
|
resolution: "file-entry-cache@npm:8.0.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user