feat: add city/state/country to complex, new settings page with sidebar, and Biome linting
- Added city, state, and country optional fields to Complex model - Updated onboarding to include optional location fields - Created new settings page with sidebar navigation (Datos del Complejo, Canchas) - Replaced ESLint with Biome for frontend and backend linting - Added parallel dev script with concurrently - Migrated register-routes to use direct app.route() pattern
This commit is contained in:
@@ -1,50 +1,50 @@
|
||||
import { PrismaPg } from '@prisma/adapter-pg'
|
||||
import { PrismaClient } from '@/generated/prisma/client'
|
||||
import { PrismaClient } from '@/generated/prisma/client';
|
||||
import { PrismaPg } from '@prisma/adapter-pg';
|
||||
|
||||
const globalForPrisma = globalThis as unknown as { prisma?: PrismaClient }
|
||||
const globalForPrisma = globalThis as unknown as { prisma?: PrismaClient };
|
||||
|
||||
function hasExpectedDelegates(client: PrismaClient) {
|
||||
const prismaClient = client as unknown as {
|
||||
court?: { findMany?: unknown }
|
||||
sport?: { findMany?: unknown }
|
||||
}
|
||||
court?: { findMany?: unknown };
|
||||
sport?: { findMany?: unknown };
|
||||
};
|
||||
|
||||
return (
|
||||
typeof prismaClient.court?.findMany === 'function' &&
|
||||
typeof prismaClient.sport?.findMany === 'function'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function buildPrismaClient() {
|
||||
const databaseUrl = Bun.env.DATABASE_URL
|
||||
const databaseUrl = Bun.env.DATABASE_URL;
|
||||
|
||||
if (!databaseUrl) {
|
||||
throw new Error('Missing DATABASE_URL in backend environment.')
|
||||
throw new Error('Missing DATABASE_URL in backend environment.');
|
||||
}
|
||||
|
||||
const adapter = new PrismaPg({
|
||||
connectionString: databaseUrl,
|
||||
})
|
||||
});
|
||||
|
||||
return new PrismaClient({ adapter })
|
||||
return new PrismaClient({ adapter });
|
||||
}
|
||||
|
||||
export function getPrismaClient() {
|
||||
if (globalForPrisma.prisma && hasExpectedDelegates(globalForPrisma.prisma)) {
|
||||
return globalForPrisma.prisma
|
||||
return globalForPrisma.prisma;
|
||||
}
|
||||
|
||||
if (globalForPrisma.prisma && !hasExpectedDelegates(globalForPrisma.prisma)) {
|
||||
void globalForPrisma.prisma.$disconnect()
|
||||
void globalForPrisma.prisma.$disconnect();
|
||||
}
|
||||
|
||||
const prisma = buildPrismaClient()
|
||||
const prisma = buildPrismaClient();
|
||||
|
||||
if (Bun.env.NODE_ENV !== 'production') {
|
||||
globalForPrisma.prisma = prisma
|
||||
globalForPrisma.prisma = prisma;
|
||||
}
|
||||
|
||||
return prisma
|
||||
return prisma;
|
||||
}
|
||||
|
||||
export const db = getPrismaClient()
|
||||
export const db = getPrismaClient();
|
||||
|
||||
Reference in New Issue
Block a user