mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
build: pnpm (#9806)
This commit is contained in:
@@ -4,9 +4,17 @@ import { connect } from '@planetscale/database';
|
||||
|
||||
const sql = connect({
|
||||
url: process.env.DATABASE_URL!,
|
||||
async fetch(url, init) {
|
||||
delete init?.cache;
|
||||
return fetch(url, { ...init, next: { revalidate: 3_600 } });
|
||||
},
|
||||
});
|
||||
|
||||
export async function fetchVersions(packageName: string): Promise<string[]> {
|
||||
if (process.env.NEXT_PUBLIC_LOCAL_DEV || process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview') {
|
||||
return ['main'];
|
||||
}
|
||||
|
||||
const response = await fetch(`https://docs.discordjs.dev/api/info?package=${packageName}`, {
|
||||
next: { revalidate: 3_600 },
|
||||
});
|
||||
@@ -29,6 +37,16 @@ export async function fetchModelJSON(packageName: string, version: string): Prom
|
||||
}
|
||||
}
|
||||
|
||||
if (process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview') {
|
||||
const { rows } = await sql.execute('select data from documentation where name = ? and version = ?', [
|
||||
packageName,
|
||||
'main',
|
||||
]);
|
||||
|
||||
// @ts-expect-error: https://github.com/planetscale/database-js/issues/71
|
||||
return rows[0].data;
|
||||
}
|
||||
|
||||
const { rows } = await sql.execute('select data from documentation where name = ? and version = ?', [
|
||||
packageName,
|
||||
version,
|
||||
|
||||
Reference in New Issue
Block a user