Replaces many uses of logical OR (||) with nullish coalescing (??) for more accurate handling of undefined/null values. Adds explicit type annotations and interfaces to improve type safety, especially in API routes and server-side code. Updates SSH connection test handling and config parsing in installedScripts router for better reliability. Minor fixes to deduplication logic, cookie handling, and error reporting.
12 lines
326 B
TypeScript
12 lines
326 B
TypeScript
import { PrismaClient } from '@prisma/client';
|
|
|
|
const globalForPrisma = globalThis as unknown as {
|
|
prisma: PrismaClient | undefined;
|
|
};
|
|
|
|
export const prisma: PrismaClient = globalForPrisma.prisma ?? new PrismaClient({
|
|
log: ['warn', 'error']
|
|
});
|
|
|
|
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma;
|