diff --git a/package.json b/package.json index c8ee660..5d29b14 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Slash command utilities for the discord.js support server.", "scripts": { "build": "rimraf dist && tsc", - "start": "node dist/index.js", + "start": "node --enable-source-maps dist/index.js", "lint": "eslint src --ext .ts", "lint:fix": "eslint src --ext .ts --fix", "prettier": "prettier --write **/*.{ts,js,toml}", diff --git a/src/util/djsdocs.ts b/src/util/djsdocs.ts index b3c04ee..b69b195 100644 --- a/src/util/djsdocs.ts +++ b/src/util/djsdocs.ts @@ -1,6 +1,7 @@ import process from 'node:process'; import { sql } from '@vercel/postgres'; import { container } from 'tsyringe'; +import { logger } from './logger.js'; export const kDjsVersions = Symbol('DJS_VERSIONS'); @@ -48,7 +49,10 @@ export async function fetchDjsVersions(): Promise { packages: [...packages], versions, }; - } catch { + } catch (error_) { + const error = error_ as Error; + logger.error(error, error.message); + return { rows: [], versions: new Map(), @@ -60,9 +64,21 @@ export async function fetchDjsVersions(): Promise { export async function prepareDjsVersions() { const res = await fetchDjsVersions(); container.register(kDjsVersions, { useValue: res }); + logger.debug({ res }, 'Registered container after fetching versions'); + return res; } export function getDjsVersions() { - return container.resolve(kDjsVersions); + const versions = container.resolve(kDjsVersions); + logger.debug({ versions }, 'Retrieving versions from container'); + if (!versions?.versions) { + return { + rows: [], + versions: new Map(), + packages: [], + } satisfies DjsVersions; + } + + return versions; }