-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prefetch all disc images at buildtime
- Loading branch information
1 parent
0773970
commit 1c98b06
Showing
9 changed files
with
48 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { RequestMethod } from "@constants"; | ||
import { config } from "@services"; | ||
|
||
import type { Disc, RequestParams } from "@types"; | ||
|
||
const request = async <T = unknown>({ url, method, body, tags }: RequestParams) => { | ||
const res = await fetch(url, { | ||
method, | ||
headers: { | ||
Authorization: `Bearer ${config.API_KEY}` | ||
}, | ||
body: JSON.stringify(body), | ||
next: { tags } | ||
}); | ||
return res.json() as Promise<T>; | ||
}; | ||
|
||
export const API = { | ||
getDiscs: async () => | ||
request<Disc[]>({ | ||
url: `${config.API_URL}/disc`, | ||
method: RequestMethod.GET, | ||
tags: ["disc"] | ||
}), | ||
fetchMany: async (urls: string[]) => Promise.allSettled(urls.map(url => fetch(url, { next: { tags: ["image"] } }))) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./api"; | ||
export * from "./config"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters