2304f95ac1
Harden geolocation with watchdog timeouts and permission checks so desktop browsers without GPS no longer hang Live-Log. Show a hint to log a position when none exists for the day. Return 503 when crew-pool Prisma models are missing instead of crashing. Co-authored-by: Cursor <cursoragent@cursor.com>
26 lines
861 B
TypeScript
26 lines
861 B
TypeScript
import { prisma } from '../db.js'
|
|
|
|
/** Prisma client includes delegates only after `npx prisma generate` on the current schema. */
|
|
export function hasCrewPoolPrismaModels(): boolean {
|
|
const client = prisma as unknown as {
|
|
personPayload?: { findMany: unknown }
|
|
logbookCrewSelectionPayload?: { findUnique: unknown }
|
|
}
|
|
return (
|
|
typeof client.personPayload?.findMany === 'function' &&
|
|
typeof client.logbookCrewSelectionPayload?.findUnique === 'function'
|
|
)
|
|
}
|
|
|
|
export const CREW_POOL_MIGRATION_HINT =
|
|
'Crew-Pool-Datenbank fehlt. Im Ordner server ausführen: npx prisma generate && npx prisma db push — danach Server neu starten.'
|
|
|
|
export function isMissingPrismaTable(error: unknown): boolean {
|
|
return (
|
|
typeof error === 'object' &&
|
|
error !== null &&
|
|
'code' in error &&
|
|
(error as { code: string }).code === 'P2021'
|
|
)
|
|
}
|