feat: local and preview detection

This commit is contained in:
iCrawl
2024-03-03 02:27:52 +01:00
parent 2848591e21
commit 79fbda3aac
33 changed files with 1069 additions and 1035 deletions

View File

@@ -1,8 +1,13 @@
import { sql } from '@vercel/postgres';
import { NextResponse, type NextRequest } from 'next/server';
import { PACKAGES } from './util/constants';
import { ENV } from './util/env';
async function fetchLatestVersion(packageName: string): Promise<string> {
if (ENV.IS_LOCAL_DEV) {
return 'main';
}
const { rows } = await sql`select version from documentation where name = ${packageName} order by version desc`;
return rows.map((row) => row.version).at(1) ?? 'main';