Skip to content

Commit f78b11b

Browse files
committed
(thunderstore-api) Refactor API fetch functions to remove async/await where unnecessary for improved performance
1 parent 1ec8acc commit f78b11b

39 files changed

+265
-360
lines changed

packages/thunderstore-api/src/delete/packageWiki.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
packageWikiPageDeleteRequestDataSchema,
77
} from "../schemas/requestSchemas";
88

9-
export async function deletePackageWikiPage(
9+
export function deletePackageWikiPage(
1010
props: ApiEndpointProps<
1111
PackageWikiPageDeleteRequestParams,
1212
object,
@@ -16,15 +16,13 @@ export async function deletePackageWikiPage(
1616
const { config, params, data } = props;
1717
const path = `api/experimental/package/${params.namespace_id}/${params.package_name}/wiki/`;
1818

19-
return await apiFetch({
20-
args: {
21-
config: config,
22-
path: path,
23-
request: {
24-
method: "DELETE",
25-
cache: "no-store",
26-
body: JSON.stringify(data),
27-
},
19+
return apiFetch({
20+
config: config,
21+
path: path,
22+
request: {
23+
method: "DELETE",
24+
cache: "no-store",
25+
body: JSON.stringify(data),
2826
},
2927
requestSchema: packageWikiPageDeleteRequestDataSchema,
3028
queryParamsSchema: undefined,

packages/thunderstore-api/src/delete/teamDisband.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@ export function teamDisband(
99
const path = `/api/cyberstorm/team/${params.team_name}/disband/`;
1010

1111
return apiFetch({
12-
args: {
13-
config,
14-
path,
15-
request: {
16-
method: "DELETE",
17-
},
18-
useSession: true,
12+
config,
13+
path,
14+
request: {
15+
method: "DELETE",
1916
},
17+
useSession: true,
2018
requestSchema: undefined,
2119
queryParamsSchema: undefined,
2220
responseSchema: undefined,

packages/thunderstore-api/src/delete/teamRemoveMember.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@ export function teamRemoveMember(
1111
const path = `/api/cyberstorm/team/${params.team_name}/member/${params.username}/remove/`;
1212

1313
return apiFetch({
14-
args: {
15-
config,
16-
path,
17-
request: {
18-
method: "DELETE",
19-
},
20-
useSession: true,
14+
config,
15+
path,
16+
request: {
17+
method: "DELETE",
2118
},
19+
useSession: true,
2220
requestSchema: undefined,
2321
queryParamsSchema: undefined,
2422
responseSchema: undefined,

packages/thunderstore-api/src/delete/teamServiceAccountRemove.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@ export function teamServiceAccountRemove(
1111
const path = `/api/cyberstorm/service-account/${params.uuid}/delete/`;
1212

1313
return apiFetch({
14-
args: {
15-
config,
16-
path,
17-
request: {
18-
method: "DELETE",
19-
},
20-
useSession: true,
14+
config,
15+
path,
16+
request: {
17+
method: "DELETE",
2118
},
19+
useSession: true,
2220
requestSchema: undefined,
2321
queryParamsSchema: undefined,
2422
responseSchema: undefined,

packages/thunderstore-api/src/delete/userDelete.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ export function userDelete(
88
const path = `/api/cyberstorm/user/delete/`;
99

1010
return apiFetch({
11-
args: {
12-
config,
13-
path,
14-
request: {
15-
method: "DELETE",
16-
},
17-
useSession: true,
11+
config,
12+
path,
13+
request: {
14+
method: "DELETE",
1815
},
16+
useSession: true,
1917
requestSchema: undefined,
2018
queryParamsSchema: undefined,
2119
responseSchema: undefined,

packages/thunderstore-api/src/delete/userLinkedAccountDisconnect.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@ export function userLinkedAccountDisconnect(
1616
const path = `/api/cyberstorm/user/linked-account/${params.provider}/disconnect/`;
1717

1818
return apiFetch({
19-
args: {
20-
config,
21-
path,
22-
request: {
23-
method: "DELETE",
24-
},
25-
useSession: true,
19+
config,
20+
path,
21+
request: {
22+
method: "DELETE",
2623
},
24+
useSession: true,
2725
requestSchema: userLinkedAccountDisconnectRequestDataSchema,
2826
queryParamsSchema: undefined,
2927
responseSchema: undefined,

packages/thunderstore-api/src/get/community.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@ import {
66
communityResponseDataSchema,
77
} from "../schemas/responseSchemas";
88

9-
export async function fetchCommunity(
9+
export function fetchCommunity(
1010
props: ApiEndpointProps<CommunityRequestParams, object, object>
1111
): Promise<CommunityResponseData> {
1212
const { config, params } = props;
1313
const path = `api/cyberstorm/community/${params.community_id}/`;
1414

15-
return await apiFetch({
16-
args: {
17-
config,
18-
path,
19-
},
15+
return apiFetch({
16+
config,
17+
path,
2018
requestSchema: undefined,
2119
queryParamsSchema: undefined,
2220
responseSchema: communityResponseDataSchema,

packages/thunderstore-api/src/get/communityFilters.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,15 @@ import {
99
communityFiltersResponseDataSchema,
1010
} from "../schemas/responseSchemas";
1111

12-
export async function fetchCommunityFilters(
12+
export function fetchCommunityFilters(
1313
props: ApiEndpointProps<CommunityFiltersRequestParams, object, object>
1414
): Promise<CommunityFiltersResponseData> {
1515
const { config, params } = props;
1616
const path = `api/cyberstorm/community/${params.community_id}/filters/`;
1717

18-
return await apiFetch({
19-
args: {
20-
config,
21-
path,
22-
},
18+
return apiFetch({
19+
config,
20+
path,
2321
requestSchema: undefined,
2422
queryParamsSchema: communityFiltersRequestParamsSchema,
2523
responseSchema: communityFiltersResponseDataSchema,

packages/thunderstore-api/src/get/communityList.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
communityListResponseDataSchema,
1111
} from "../schemas/responseSchemas";
1212

13-
export async function fetchCommunityList(
13+
export function fetchCommunityList(
1414
props: ApiEndpointProps<object, CommunityListRequestQueryParams, object>
1515
): Promise<CommunityListResponseData> {
1616
const {
@@ -27,12 +27,10 @@ export async function fetchCommunityList(
2727
} = props;
2828
const path = "api/cyberstorm/community/";
2929

30-
return await apiFetch({
31-
args: {
32-
config,
33-
path,
34-
queryParams,
35-
},
30+
return apiFetch({
31+
config,
32+
path,
33+
queryParams,
3634
requestSchema: undefined,
3735
queryParamsSchema: communityListRequestQueryParamsSchema,
3836
responseSchema: communityListResponseDataSchema,

packages/thunderstore-api/src/get/communityPackageListings.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
packageListingsResponseDataSchema,
1313
} from "../schemas/responseSchemas";
1414

15-
export async function fetchCommunityPackageListings(
15+
export function fetchCommunityPackageListings(
1616
props: ApiEndpointProps<
1717
CommunityPackageListingsRequestParams,
1818
PackageListingsRequestQueryParams,
@@ -37,12 +37,10 @@ export async function fetchCommunityPackageListings(
3737
{ key: "deprecated", value: false, impotent: false },
3838
],
3939
} = props;
40-
return await apiFetch({
41-
args: {
42-
config,
43-
path: `api/cyberstorm/listing/${params.community_id.toLowerCase()}/`,
44-
queryParams,
45-
},
40+
return apiFetch({
41+
config,
42+
path: `api/cyberstorm/listing/${params.community_id.toLowerCase()}/`,
43+
queryParams,
4644
requestSchema: communityPackageListingsRequestParamsSchema,
4745
queryParamsSchema: packageListingsRequestQueryParamsSchema,
4846
responseSchema: packageListingsResponseDataSchema,

0 commit comments

Comments
 (0)