chore: delete empty features module, fix RaceRow timestamp types
Some checks failed
CI / build-and-test (pull_request) Has been cancelled
Some checks failed
CI / build-and-test (pull_request) Has been cancelled
- Remove dead frontend/src/features/index.ts (empty export, unused) - RaceRow: created_at/updated_at typed as Date to match pg TIMESTAMPTZ runtime - rowToDto: explicit toISOString() conversion instead of relying on JSON.stringify - Mock DB: return Date objects for timestamp fields to match real pg behavior Made-with: Cursor
This commit is contained in:
@@ -15,7 +15,7 @@ const poolConfig: PoolConfig = {
|
|||||||
|
|
||||||
function mockRowFromInsert(sql: string, params: unknown[]): RaceRow {
|
function mockRowFromInsert(sql: string, params: unknown[]): RaceRow {
|
||||||
const match = sql.match(/INSERT INTO races\s*\(([^)]+)\)\s*VALUES/i);
|
const match = sql.match(/INSERT INTO races\s*\(([^)]+)\)\s*VALUES/i);
|
||||||
const now = new Date().toISOString();
|
const now = new Date();
|
||||||
if (!match) {
|
if (!match) {
|
||||||
return {
|
return {
|
||||||
id: String(params[0] ?? ""),
|
id: String(params[0] ?? ""),
|
||||||
@@ -108,7 +108,7 @@ function createMockPool(): Pool {
|
|||||||
if (!existing) {
|
if (!existing) {
|
||||||
return emptyResult();
|
return emptyResult();
|
||||||
}
|
}
|
||||||
const updated = { ...existing, updated_at: new Date().toISOString() };
|
const updated = { ...existing, updated_at: new Date() };
|
||||||
store.set(id, updated);
|
store.set(id, updated);
|
||||||
return {
|
return {
|
||||||
rows: [updated as unknown as T],
|
rows: [updated as unknown as T],
|
||||||
|
|||||||
@@ -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 {
|
export interface RaceRow {
|
||||||
id: string;
|
id: string;
|
||||||
race_date: string;
|
race_date: string;
|
||||||
@@ -13,8 +16,8 @@ export interface RaceRow {
|
|||||||
finish_time: string | null;
|
finish_time: string | null;
|
||||||
finish_place: string | null;
|
finish_place: string | null;
|
||||||
notes: string | null;
|
notes: string | null;
|
||||||
created_at: string;
|
created_at: Date;
|
||||||
updated_at: string | null;
|
updated_at: Date | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** API shape (camelCase). */
|
/** API shape (camelCase). */
|
||||||
@@ -36,6 +39,10 @@ export interface RaceDto {
|
|||||||
updatedAt: string | null;
|
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). */
|
/** Convert a DB row to the API DTO (camelCase). */
|
||||||
export function rowToDto(row: RaceRow): RaceDto {
|
export function rowToDto(row: RaceRow): RaceDto {
|
||||||
return {
|
return {
|
||||||
@@ -52,8 +59,8 @@ export function rowToDto(row: RaceRow): RaceDto {
|
|||||||
finishTime: row.finish_time,
|
finishTime: row.finish_time,
|
||||||
finishPlace: row.finish_place,
|
finishPlace: row.finish_place,
|
||||||
notes: row.notes,
|
notes: row.notes,
|
||||||
createdAt: row.created_at,
|
createdAt: toISOString(row.created_at),
|
||||||
updatedAt: row.updated_at,
|
updatedAt: row.updated_at ? toISOString(row.updated_at) : null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
export {};
|
|
||||||
Reference in New Issue
Block a user