refactor: switch to vercel blob for docs

This commit is contained in:
iCrawl
2023-11-13 23:15:16 +01:00
parent ffc3ea5c3f
commit 01c63d2e0f
9 changed files with 278 additions and 69 deletions

View File

@@ -3,6 +3,7 @@ import { setFailed } from '@actions/core';
import { generateAllIndices } from '@discordjs/scripts';
import { createPool } from '@vercel/postgres';
import { MeiliSearch } from 'meilisearch';
import { fetch } from 'undici';
if (!process.env.DATABASE_URL) {
setFailed('DATABASE_URL is not set');
@@ -36,9 +37,10 @@ try {
},
fetchPackageVersionDocs: async (pkg, version) => {
console.log(`Fetching data for ${pkg} ${version}...`);
const { rows } = await pool.sql`select data from documentation where name = ${pkg} and version = ${version}`;
const { rows } = await pool.sql`select url from documentation where name = ${pkg} and version = ${version}`;
const res = await fetch(rows[0]?.url ?? '');
return rows[0]?.data ?? null;
return res.json();
},
writeToFile: false,
});