mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Converted global to globalThis.
This commit is contained in:
parent
886b7e9e56
commit
c969603001
9 changed files with 25 additions and 22 deletions
|
|
@ -1,7 +1,8 @@
|
||||||
generator client {
|
generator client {
|
||||||
provider = "prisma-client-js"
|
provider = "prisma-client"
|
||||||
output = "../src/generated/prisma"
|
output = "../src/generated/prisma"
|
||||||
binaryTargets = ["native"]
|
binaryTargets = ["native"]
|
||||||
|
moduleFormat = "esm"
|
||||||
}
|
}
|
||||||
|
|
||||||
datasource db {
|
datasource db {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
generator client {
|
generator client {
|
||||||
provider = "prisma-client-js"
|
provider = "prisma-client"
|
||||||
output = "../src/generated/prisma"
|
output = "../src/generated/prisma"
|
||||||
binaryTargets = ["native"]
|
binaryTargets = ["native"]
|
||||||
|
moduleFormat = "esm"
|
||||||
}
|
}
|
||||||
|
|
||||||
datasource db {
|
datasource db {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "umami",
|
"name": "umami",
|
||||||
"version": "2.18.0",
|
"version": "3.0.0",
|
||||||
"description": "A modern, privacy-focused alternative to Google Analytics.",
|
"description": "A modern, privacy-focused alternative to Google Analytics.",
|
||||||
"author": "Umami Software, Inc. <hello@umami.is>",
|
"author": "Umami Software, Inc. <hello@umami.is>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
"set-routes-manifest": "node scripts/set-routes-manifest.mjs",
|
"set-routes-manifest": "node scripts/set-routes-manifest.mjs",
|
||||||
"update-tracker": "node scripts/update-tracker.mjs",
|
"update-tracker": "node scripts/update-tracker.mjs",
|
||||||
"update-db": "prisma migrate deploy",
|
"update-db": "prisma migrate deploy",
|
||||||
"check-db": "node scripts/check-db.js",
|
"check-db": "node scripts/check-db.mjs",
|
||||||
"check-env": "node scripts/check-env.mjs",
|
"check-env": "node scripts/check-env.mjs",
|
||||||
"copy-db-files": "node scripts/copy-db-files.mjs",
|
"copy-db-files": "node scripts/copy-db-files.mjs",
|
||||||
"extract-messages": "formatjs extract \"src/components/messages.ts\" --out-file build/extracted-messages.json",
|
"extract-messages": "formatjs extract \"src/components/messages.ts\" --out-file build/extracted-messages.json",
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
require('dotenv').config();
|
import 'dotenv/config';
|
||||||
const { PrismaClient } = require('@prisma/client');
|
|
||||||
const chalk = require('chalk');
|
import { PrismaClient } from '../src/generated/prisma/client';
|
||||||
const { execSync } = require('child_process');
|
import chalk from 'chalk';
|
||||||
const semver = require('semver');
|
import { execSync } from 'child_process';
|
||||||
|
import semver from 'semver';
|
||||||
|
|
||||||
if (process.env.SKIP_DB_CHECK) {
|
if (process.env.SKIP_DB_CHECK) {
|
||||||
console.log('Skipping database check.');
|
console.log('Skipping database check.');
|
||||||
|
|
@ -41,7 +41,7 @@ function getClient() {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
global[CLICKHOUSE] = client;
|
globalThis[CLICKHOUSE] = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
log('Clickhouse initialized');
|
log('Clickhouse initialized');
|
||||||
|
|
@ -219,7 +219,7 @@ async function findFirst(data: any[]) {
|
||||||
|
|
||||||
async function connect() {
|
async function connect() {
|
||||||
if (enabled && !clickhouse) {
|
if (enabled && !clickhouse) {
|
||||||
clickhouse = process.env.CLICKHOUSE_URL && (global[CLICKHOUSE] || getClient());
|
clickhouse = process.env.CLICKHOUSE_URL && (globalThis[CLICKHOUSE] || getClient());
|
||||||
}
|
}
|
||||||
|
|
||||||
return clickhouse;
|
return clickhouse;
|
||||||
|
|
|
||||||
|
|
@ -121,13 +121,13 @@ export async function getLocation(ip: string = '', headers: Headers, hasPayloadI
|
||||||
}
|
}
|
||||||
|
|
||||||
// Database lookup
|
// Database lookup
|
||||||
if (!global[MAXMIND]) {
|
if (!globalThis[MAXMIND]) {
|
||||||
const dir = path.join(process.cwd(), 'geo');
|
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) {
|
if (result) {
|
||||||
const country = result.country?.iso_code ?? result?.registered_country?.iso_code;
|
const country = result.country?.iso_code ?? result?.registered_country?.iso_code;
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ function getClient() {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
global[KAFKA] = client;
|
globalThis[KAFKA] = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
log('Kafka initialized');
|
log('Kafka initialized');
|
||||||
|
|
@ -54,7 +54,7 @@ async function getProducer(): Promise<Producer> {
|
||||||
await producer.connect();
|
await producer.connect();
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
global[KAFKA_PRODUCER] = producer;
|
globalThis[KAFKA_PRODUCER] = producer;
|
||||||
}
|
}
|
||||||
|
|
||||||
log('Kafka producer initialized');
|
log('Kafka producer initialized');
|
||||||
|
|
@ -91,10 +91,10 @@ async function sendMessage(
|
||||||
|
|
||||||
async function connect(): Promise<Kafka> {
|
async function connect(): Promise<Kafka> {
|
||||||
if (!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) {
|
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') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
global[PRISMA] = prisma;
|
globalThis[PRISMA] = prisma;
|
||||||
}
|
}
|
||||||
|
|
||||||
log('Prisma initialized');
|
log('Prisma initialized');
|
||||||
|
|
@ -380,7 +380,7 @@ function getClient(params?: {
|
||||||
return prisma;
|
return prisma;
|
||||||
}
|
}
|
||||||
|
|
||||||
const client = global[PRISMA] || getClient();
|
const client = globalThis[PRISMA] || getClient();
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
client,
|
client,
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,12 @@ function getClient() {
|
||||||
const redis = new UmamiRedisClient(process.env.REDIS_URL);
|
const redis = new UmamiRedisClient(process.env.REDIS_URL);
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
global[REDIS] = redis;
|
globalThis[REDIS] = redis;
|
||||||
}
|
}
|
||||||
|
|
||||||
return redis;
|
return redis;
|
||||||
}
|
}
|
||||||
|
|
||||||
const client = global[REDIS] || getClient();
|
const client = globalThis[REDIS] || getClient();
|
||||||
|
|
||||||
export default { client, enabled };
|
export default { client, enabled };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue