chore: deps

This commit is contained in:
iCrawl
2024-03-11 17:50:39 +01:00
parent 5f2095b76c
commit 0d4c26ba4c
32 changed files with 2218 additions and 2304 deletions

View File

@@ -1,5 +1,6 @@
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
import { notFound } from 'next/navigation';
import { ENV } from './env';
export async function fetchNode({
@@ -14,17 +15,27 @@ export async function fetchNode({
const normalizeItem = item.split(encodeURIComponent(':')).join('.').toLowerCase();
if (ENV.IS_LOCAL_DEV) {
const fileContent = await readFile(
join(process.cwd(), `../../packages/${packageName}/docs/split/${version}.${normalizeItem}.api.json`),
'utf8',
);
return JSON.parse(fileContent);
try {
const fileContent = await readFile(
join(process.cwd(), `../../packages/${packageName}/docs/split/${version}.${normalizeItem}.api.json`),
'utf8',
);
return JSON.parse(fileContent);
} catch {
notFound();
}
}
const isMainVersion = version === 'main';
const fileContent = await fetch(
`${process.env.BLOB_STORAGE_URL}/rewrite/${packageName}/${version}.${normalizeItem}.api.json`,
{ next: isMainVersion ? { revalidate: 0 } : { revalidate: 604_800 } },
);
return fileContent.json();
try {
const isMainVersion = version === 'main';
const fileContent = await fetch(
`${process.env.BLOB_STORAGE_URL}/rewrite/${packageName}/${version}.${normalizeItem}.api.json`,
{ next: isMainVersion ? { revalidate: 0 } : { revalidate: 604_800 } },
);
return await fileContent.json();
} catch {
notFound();
}
}