diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 4fc2812..752c5fc 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -33,7 +33,8 @@ This is a crowdfunding platform for games with a developer theme. The applicatio - Make sure all guidance in the Copilot Instructions file is updated with any relevant changes, including to project structure and scripts, and programming guidance ### Code formatting requirements - +- Every exported function should have a TSDoc comment describing its purpose, parameters, and return value. +- Before imports or any code, add a comment block to the file that explains its purpose. - Use TypeScript with explicit types for function parameters and return values, especially in the data layer (`db/`, `src/lib/`) - Frontend code (TypeScript, Astro) must pass ESLint checks (`npm run lint`) diff --git a/src/lib/publishers.ts b/src/lib/publishers.ts new file mode 100644 index 0000000..12723ed --- /dev/null +++ b/src/lib/publishers.ts @@ -0,0 +1,31 @@ +/** + * Data-access helpers for publisher summary records used by Astro pages. + */ + +import { asc } from 'drizzle-orm'; +import type { Database } from './db'; +import { publishers } from '../../db/schema'; +import type { Publisher } from '../types/game'; + +type PublisherSummaryRow = { + id: number; + name: string; +}; + +/** + * Returns all publishers ordered by name. + * + * @param db - Drizzle database client. + * @returns A list of publisher summaries including only `id` and `name`. + */ +export async function getAllPublishers(db: Database): Promise { + const rows = await db + .select({ id: publishers.id, name: publishers.name }) + .from(publishers) + .orderBy(asc(publishers.name)); + + return rows.map((row: PublisherSummaryRow) => ({ + id: row.id, + name: row.name, + })); +}