refactor: use planetscale instead of custom api

This commit is contained in:
iCrawl
2023-11-07 15:08:03 +01:00
parent 344a3f9344
commit 009c0a3bae
10 changed files with 131 additions and 69 deletions

View File

@@ -15,11 +15,12 @@ export async function fetchVersions(packageName: string): Promise<string[]> {
return ['main'];
}
const response = await fetch(`https://docs.discordjs.dev/api/info?package=${packageName}`, {
next: { revalidate: 3_600 },
});
const { rows } = await sql.execute('select version from documentation where name = ? order by version desc', [
packageName,
]);
return response.json();
// @ts-expect-error: https://github.com/planetscale/database-js/issues/71
return rows[0].data;
}
export async function fetchModelJSON(packageName: string, version: string): Promise<unknown> {