fix: logins now refresh on plugins load
feat: Added tar archive support fix: Downloaded games and emulator execute permission now updated fix: Fixed rclone for linux fix: on screen keyaboard only now shows up when using a gamepad or touch
This commit is contained in:
parent
6aacec2c0d
commit
7bd0ebdcca
39 changed files with 523 additions and 275 deletions
|
|
@ -2,6 +2,7 @@ import { eq } from "drizzle-orm";
|
|||
import { cache } from "./app";
|
||||
import cacheSchema from "@schema/cache";
|
||||
import { GithubReleaseSchema } from "@/shared/constants";
|
||||
import PQueue from "p-queue";
|
||||
|
||||
export const CACHE_KEYS = {
|
||||
ROM_PLATFORMS: 'rom-platforms',
|
||||
|
|
@ -9,6 +10,8 @@ export const CACHE_KEYS = {
|
|||
STORE_GAME_MANIFEST: 'store-game-manifest'
|
||||
} as const;
|
||||
|
||||
export const githubRequestQueue = new PQueue({ intervalCap: 10, interval: 1000 * 60 * 10, strict: true });
|
||||
|
||||
export async function getOrCached<T> (key: string, getter: () => Promise<T>, options?: { expireMs?: number; }): Promise<T>
|
||||
{
|
||||
const cached = await cache.query.item_cache.findFirst({ where: eq(cacheSchema.item_cache.key, key) });
|
||||
|
|
@ -37,10 +40,10 @@ export async function getOrCached<T> (key: string, getter: () => Promise<T>, opt
|
|||
|
||||
export async function getOrCachedGithubRelease (path: string)
|
||||
{
|
||||
return getOrCached(`github-release-${path}`, async () =>
|
||||
return getOrCached(`github-release-${path}`, async () => githubRequestQueue.add(async () =>
|
||||
{
|
||||
const response = await fetch(`https://api.github.com/repos/${path}/releases/latest`, { method: "GET" });
|
||||
if (!response.ok) throw new Error(response.statusText);
|
||||
return GithubReleaseSchema.parseAsync(await response.json());
|
||||
});
|
||||
}), { expireMs: 1000 * 60 * 60 });
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue