mirror of
https://github.com/LukeHagar/pypistats.dev.git
synced 2025-12-06 04:21:09 +00:00
Add bun.lockb file and update docker-compose.yml to remove sensitive environment variables. Refactor package.json to reorganize dependencies and add Bun types. Modify tsconfig.json to include Bun types. Update Redis client implementation in redis.ts for improved error handling and connection management.
This commit is contained in:
@@ -40,8 +40,6 @@ services:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
SERVICE_PASSWORD_POSTGRES: ${POSTGRES_PASSWORD}
|
||||
SERVICE_PASSWORD_REDIS: ${REDIS_PASSWORD}
|
||||
DATABASE_URL: postgresql://pypistats:${POSTGRES_PASSWORD}@db:5432/pypistats?schema=public
|
||||
REDIS_URL: redis://:${REDIS_PASSWORD}@redis:6379
|
||||
GOOGLE_APPLICATION_CREDENTIALS_BASE64: ${GOOGLE_APPLICATION_CREDENTIALS_BASE64}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"db:migrate": "prisma migrate dev",
|
||||
"db:deploy": "prisma migrate deploy"
|
||||
},
|
||||
"dependencies": {
|
||||
"devDependencies": {
|
||||
"@google-cloud/bigquery": "^8.1.1",
|
||||
"@prisma/client": "^6.15.0",
|
||||
"@sveltejs/adapter-node": "^5.3.1",
|
||||
@@ -26,9 +26,7 @@
|
||||
"chart.js": "^4.5.0",
|
||||
"chartjs-node-canvas": "^5.0.0",
|
||||
"node-cron": "^4.2.1",
|
||||
"redis": "^5.8.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"redis": "^5.8.2",
|
||||
"@plausible-analytics/tracker": "^0.4.0",
|
||||
"@sveltejs/adapter-auto": "^6.1.0",
|
||||
"@sveltejs/kit": "^2.37.0",
|
||||
@@ -36,6 +34,7 @@
|
||||
"@tailwindcss/forms": "^0.5.10",
|
||||
"@tailwindcss/typography": "^0.5.16",
|
||||
"@tailwindcss/vite": "^4.1.12",
|
||||
"@types/bun": "^1.3.0",
|
||||
"mdsvex": "^0.12.6",
|
||||
"prettier": "^3.6.2",
|
||||
"prettier-plugin-svelte": "^3.4.0",
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const globalForPrisma = globalThis as unknown as {
|
||||
prisma: PrismaClient | undefined;
|
||||
};
|
||||
export const prisma = new PrismaClient();
|
||||
|
||||
export const prisma = globalForPrisma.prisma ?? new PrismaClient();
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma;
|
||||
@@ -1,3 +1,4 @@
|
||||
import { env } from '$env/dynamic/private';
|
||||
import { createClient } from 'redis';
|
||||
|
||||
// Redis client instance
|
||||
@@ -6,14 +7,7 @@ let isConnecting = false;
|
||||
let isDisconnecting = false;
|
||||
|
||||
export function getRedisClient() {
|
||||
const redisUrl = process.env.REDIS_URL;
|
||||
// Skip connecting if no REDIS_URL is provided (e.g., during build)
|
||||
if (!redisUrl) {
|
||||
if (typeof process !== 'undefined') {
|
||||
console.warn('Redis disabled: REDIS_URL not set');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
const redisUrl = env.REDIS_URL;
|
||||
|
||||
if (!redisClient && !isConnecting) {
|
||||
isConnecting = true;
|
||||
@@ -21,7 +15,7 @@ export function getRedisClient() {
|
||||
url: redisUrl,
|
||||
});
|
||||
|
||||
redisClient.on('error', (err) => {
|
||||
redisClient.on('error', (err: any) => {
|
||||
console.error('Redis Client Error:', err);
|
||||
});
|
||||
|
||||
@@ -76,7 +70,7 @@ export async function forceDisconnectRedis(): Promise<void> {
|
||||
isDisconnecting = true;
|
||||
try {
|
||||
console.log('Force disconnecting Redis client...');
|
||||
await redisClient.disconnect();
|
||||
await redisClient.destroy();
|
||||
console.log('Redis client force disconnected');
|
||||
} catch (error) {
|
||||
console.error('Error force disconnecting Redis client:', error);
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
"skipLibCheck": true,
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"moduleResolution": "bundler"
|
||||
"moduleResolution": "bundler",
|
||||
"types": ["bun"]
|
||||
}
|
||||
// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
|
||||
// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
|
||||
|
||||
Reference in New Issue
Block a user