Merge pull request 'chore: delete empty features module, fix RaceRow timestamp types' (#11) from chore/phase4-cleanup-types into main
Some checks failed
CI / build-and-test (push) Has been cancelled

Reviewed-on: #11
This commit was merged in pull request #11.
This commit is contained in:
2026-04-07 15:38:45 +00:00
3 changed files with 14 additions and 8 deletions

View File

@@ -15,7 +15,7 @@ const poolConfig: PoolConfig = {
function mockRowFromInsert(sql: string, params: unknown[]): RaceRow {
const match = sql.match(/INSERT INTO races\s*\(([^)]+)\)\s*VALUES/i);
const now = new Date().toISOString();
const now = new Date();
if (!match) {
return {
id: String(params[0] ?? ""),
@@ -108,7 +108,7 @@ function createMockPool(): Pool {
if (!existing) {
return emptyResult();
}
const updated = { ...existing, updated_at: new Date().toISOString() };
const updated = { ...existing, updated_at: new Date() };
store.set(id, updated);
return {
rows: [updated as unknown as T],

View File

@@ -1,4 +1,7 @@
/** Row shape returned by PostgreSQL (snake_case). */
/**
* Row shape returned by PostgreSQL (snake_case).
* pg returns DATE as string, NUMERIC as string, TIMESTAMPTZ as Date.
*/
export interface RaceRow {
id: string;
race_date: string;
@@ -13,8 +16,8 @@ export interface RaceRow {
finish_time: string | null;
finish_place: string | null;
notes: string | null;
created_at: string;
updated_at: string | null;
created_at: Date;
updated_at: Date | null;
}
/** API shape (camelCase). */
@@ -36,6 +39,10 @@ export interface RaceDto {
updatedAt: string | null;
}
function toISOString(value: Date | string): string {
return value instanceof Date ? value.toISOString() : String(value);
}
/** Convert a DB row to the API DTO (camelCase). */
export function rowToDto(row: RaceRow): RaceDto {
return {
@@ -52,8 +59,8 @@ export function rowToDto(row: RaceRow): RaceDto {
finishTime: row.finish_time,
finishPlace: row.finish_place,
notes: row.notes,
createdAt: row.created_at,
updatedAt: row.updated_at,
createdAt: toISOString(row.created_at),
updatedAt: row.updated_at ? toISOString(row.updated_at) : null,
};
}

View File

@@ -1 +0,0 @@
export {};