mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 06:37:18 +01:00
Converted global to globalThis.
This commit is contained in:
parent
886b7e9e56
commit
c969603001
9 changed files with 25 additions and 22 deletions
|
|
@ -41,7 +41,7 @@ function getClient() {
|
|||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
global[CLICKHOUSE] = client;
|
||||
globalThis[CLICKHOUSE] = client;
|
||||
}
|
||||
|
||||
log('Clickhouse initialized');
|
||||
|
|
@ -219,7 +219,7 @@ async function findFirst(data: any[]) {
|
|||
|
||||
async function connect() {
|
||||
if (enabled && !clickhouse) {
|
||||
clickhouse = process.env.CLICKHOUSE_URL && (global[CLICKHOUSE] || getClient());
|
||||
clickhouse = process.env.CLICKHOUSE_URL && (globalThis[CLICKHOUSE] || getClient());
|
||||
}
|
||||
|
||||
return clickhouse;
|
||||
|
|
|
|||
|
|
@ -121,13 +121,13 @@ export async function getLocation(ip: string = '', headers: Headers, hasPayloadI
|
|||
}
|
||||
|
||||
// Database lookup
|
||||
if (!global[MAXMIND]) {
|
||||
if (!globalThis[MAXMIND]) {
|
||||
const dir = path.join(process.cwd(), 'geo');
|
||||
|
||||
global[MAXMIND] = await maxmind.open(path.resolve(dir, 'GeoLite2-City.mmdb'));
|
||||
globalThis[MAXMIND] = await maxmind.open(path.resolve(dir, 'GeoLite2-City.mmdb'));
|
||||
}
|
||||
|
||||
const result = global[MAXMIND].get(ip);
|
||||
const result = globalThis[MAXMIND].get(ip);
|
||||
|
||||
if (result) {
|
||||
const country = result.country?.iso_code ?? result?.registered_country?.iso_code;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ function getClient() {
|
|||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
global[KAFKA] = client;
|
||||
globalThis[KAFKA] = client;
|
||||
}
|
||||
|
||||
log('Kafka initialized');
|
||||
|
|
@ -54,7 +54,7 @@ async function getProducer(): Promise<Producer> {
|
|||
await producer.connect();
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
global[KAFKA_PRODUCER] = producer;
|
||||
globalThis[KAFKA_PRODUCER] = producer;
|
||||
}
|
||||
|
||||
log('Kafka producer initialized');
|
||||
|
|
@ -91,10 +91,10 @@ async function sendMessage(
|
|||
|
||||
async function connect(): Promise<Kafka> {
|
||||
if (!kafka) {
|
||||
kafka = process.env.KAFKA_URL && process.env.KAFKA_BROKER && (global[KAFKA] || getClient());
|
||||
kafka = process.env.KAFKA_URL && process.env.KAFKA_BROKER && (globalThis[KAFKA] || getClient());
|
||||
|
||||
if (kafka) {
|
||||
producer = global[KAFKA_PRODUCER] || (await getProducer());
|
||||
producer = globalThis[KAFKA_PRODUCER] || (await getProducer());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -372,7 +372,7 @@ function getClient(params?: {
|
|||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
global[PRISMA] = prisma;
|
||||
globalThis[PRISMA] = prisma;
|
||||
}
|
||||
|
||||
log('Prisma initialized');
|
||||
|
|
@ -380,7 +380,7 @@ function getClient(params?: {
|
|||
return prisma;
|
||||
}
|
||||
|
||||
const client = global[PRISMA] || getClient();
|
||||
const client = globalThis[PRISMA] || getClient();
|
||||
|
||||
export default {
|
||||
client,
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ function getClient() {
|
|||
const redis = new UmamiRedisClient(process.env.REDIS_URL);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
global[REDIS] = redis;
|
||||
globalThis[REDIS] = redis;
|
||||
}
|
||||
|
||||
return redis;
|
||||
}
|
||||
|
||||
const client = global[REDIS] || getClient();
|
||||
const client = globalThis[REDIS] || getClient();
|
||||
|
||||
export default { client, enabled };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue