added chunithm version selector in admin settings
This commit is contained in:
@ -1,20 +1,36 @@
|
||||
import { PrismaClient as daphnisClient } from "@/prisma/schemas/daphnis/generated/daphnis";
|
||||
import { PrismaClient as artemisClient } from "@/prisma/schemas/artemis/generated/artemis";
|
||||
import { PrismaClient as DaphnisClient } from "@/prisma/schemas/daphnis/generated/daphnis";
|
||||
import { PrismaClient as ArtemisClient } from "@/prisma/schemas/artemis/generated/artemis";
|
||||
|
||||
const DaphnisSingleton = () => {
|
||||
return new daphnisClient();
|
||||
// Singleton pattern for Daphnis client
|
||||
const DaphnisClientSingleton = () => {
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
return new DaphnisClient();
|
||||
}
|
||||
|
||||
// In development mode, reuse existing global instance if available
|
||||
if (globalThis.daphnisClient) {
|
||||
return globalThis.daphnisClient as DaphnisClient;
|
||||
}
|
||||
const client = new DaphnisClient();
|
||||
globalThis.daphnisClient = client;
|
||||
return client;
|
||||
};
|
||||
|
||||
const aremisSingleton = () => {
|
||||
return new artemisClient();
|
||||
// Singleton pattern for Artemis client
|
||||
const ArtemisClientSingleton = () => {
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
return new ArtemisClient();
|
||||
}
|
||||
|
||||
// In development mode, reuse existing global instance if available
|
||||
if (globalThis.artemisClient) {
|
||||
return globalThis.artemisClient as ArtemisClient;
|
||||
}
|
||||
const client = new ArtemisClient();
|
||||
globalThis.artemisClient = client;
|
||||
return client;
|
||||
};
|
||||
|
||||
declare global {
|
||||
var daphnis: undefined | ReturnType<typeof DaphnisSingleton>;
|
||||
var artemis: undefined | ReturnType<typeof aremisSingleton>;
|
||||
}
|
||||
|
||||
export const daphnis = globalThis.daphnis ?? DaphnisSingleton();
|
||||
export const artemis = globalThis.artemis ?? aremisSingleton();
|
||||
|
||||
if (process.env.NODE_ENV !== "production") globalThis.daphnis = daphnis;
|
||||
// Exporting the singletons
|
||||
export const daphnis = DaphnisClientSingleton();
|
||||
export const artemis = ArtemisClientSingleton();
|
||||
|
Reference in New Issue
Block a user