Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Comment on lines 35 to 39

Expand Down
31 changes: 31 additions & 0 deletions src/lib/publishers.ts
Original file line number Diff line number Diff line change
@@ -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<Publisher[]> {
const rows = await db
.select({ id: publishers.id, name: publishers.name })
.from(publishers)
.orderBy(asc(publishers.name));

Comment on lines +21 to +26
return rows.map((row: PublisherSummaryRow) => ({
id: row.id,
name: row.name,
}));
}