Skip to content

Commit 635eec4

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

23 files changed

+52
-53
lines changed

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

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

9-
export async function deletePackageWikiPage(
9+
export function deletePackageWikiPage(
1010
props: ApiEndpointProps<
1111
PackageWikiPageDeleteRequestParams,
1212
object,
@@ -16,7 +16,7 @@ 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({
19+
return apiFetch({
2020
args: {
2121
config: config,
2222
path: path,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import {
66
} from "../schemas/responseSchemas";
77
import { CommunityRequestParams } from "../schemas/requestSchemas";
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({
15+
return apiFetch({
1616
args: {
1717
config,
1818
path,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import {
99
CommunityFiltersResponseData,
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({
18+
return apiFetch({
1919
args: {
2020
config,
2121
path,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
CommunityListResponseData,
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,7 +27,7 @@ export async function fetchCommunityList(
2727
} = props;
2828
const path = "api/cyberstorm/community/";
2929

30-
return await apiFetch({
30+
return apiFetch({
3131
args: {
3232
config,
3333
path,

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

Lines changed: 2 additions & 2 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,7 +37,7 @@ export async function fetchCommunityPackageListings(
3737
{ key: "deprecated", value: false, impotent: false },
3838
],
3939
} = props;
40-
return await apiFetch({
40+
return apiFetch({
4141
args: {
4242
config,
4343
path: `api/cyberstorm/listing/${params.community_id.toLowerCase()}/`,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import {
55
currentUserResponseDataSchema,
66
} from "../schemas/responseSchemas";
77

8-
export async function fetchCurrentUser(
8+
export function fetchCurrentUser(
99
props: ApiEndpointProps<object, object, object>
1010
): Promise<CurrentUserResponseData> {
1111
const { config } = props;
1212
const path = "api/experimental/current-user/";
1313
const request = { cache: "no-store" as RequestCache };
1414

15-
return await apiFetch({
15+
return apiFetch({
1616
args: { config, path, request, useSession: true },
1717
requestSchema: undefined,
1818
queryParamsSchema: undefined,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import {
66
} from "../schemas/responseSchemas";
77
import { DynamicHTMLRequestParams } from "../schemas/requestSchemas";
88

9-
export async function fetchDynamicHTML(
9+
export function fetchDynamicHTML(
1010
props: ApiEndpointProps<DynamicHTMLRequestParams, object, object>
1111
): Promise<DynamicHTMLResponseData> {
1212
const { config, params } = props;
1313
const path = `api/cyberstorm/dynamichtml/${params.placement}`;
1414

15-
return await apiFetch({
15+
return apiFetch({
1616
args: { config, path, request: { cache: "no-store" as RequestCache } },
1717
requestSchema: undefined,
1818
queryParamsSchema: undefined,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from "../schemas/responseSchemas";
1212
import { PackageListingsOrderingEnum } from "../schemas/queryParamSchemas";
1313

14-
export async function fetchNamespacePackageListings(
14+
export function fetchNamespacePackageListings(
1515
props: ApiEndpointProps<
1616
NamespacePackageListingsRequestParams,
1717
PackageListingsRequestQueryParams,
@@ -38,7 +38,7 @@ export async function fetchNamespacePackageListings(
3838
} = props;
3939
const path = `api/cyberstorm/listing/${params.community_id.toLowerCase()}/${params.namespace_id.toLowerCase()}/`;
4040

41-
return await apiFetch({
41+
return apiFetch({
4242
args: {
4343
config,
4444
path,

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

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

9-
export async function fetchPackagePermissions(
9+
export function fetchPackagePermissions(
1010
props: ApiEndpointProps<PackagePermissionsRequestParams, object, object>
1111
): Promise<PackagePermissionsResponseData> {
1212
const { config, params } = props;
1313
const path = `api/cyberstorm/package/${params.community_id}/${params.namespace_id}/${params.package_name}/permissions`;
1414
const request = { cache: "no-store" as RequestCache };
1515

16-
return await apiFetch({
16+
return apiFetch({
1717
args: {
1818
config: config,
1919
path: path,

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

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

9-
export async function fetchPackageChangelog(
9+
export function fetchPackageChangelog(
1010
props: ApiEndpointProps<PackageChangelogRequestParams, object, object>
1111
): Promise<PackageChangelogResponseData> {
1212
const { config, params } = props;
@@ -16,7 +16,7 @@ export async function fetchPackageChangelog(
1616
: `v/${params.version_number}`;
1717
const path = `api/cyberstorm/package/${params.namespace_id}/${params.package_name}/${v}/changelog/`;
1818

19-
return await apiFetch({
19+
return apiFetch({
2020
args: {
2121
config,
2222
path,

0 commit comments

Comments
 (0)