From b7908da5bf59475628c2b0828f91d4a17577ee2b Mon Sep 17 00:00:00 2001 From: Kaushik Narayan R Date: Thu, 20 Mar 2025 13:53:59 -0700 Subject: [PATCH] moved from redis-stack-server to base redis , prepping for release --- .env.development | 4 ++-- .env.production | 2 ++ compose-core.yaml | 9 +++++---- compose-dev.yaml | 2 +- compose-prod.yaml | 2 +- controllers/operations.ts | 11 +++++++---- package.json | 2 +- 7 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.env.development b/.env.development index 38c642b..14b82b9 100644 --- a/.env.development +++ b/.env.development @@ -1,5 +1,5 @@ BASE_DOMAIN = 127.0.0.1 REDIRECT_URI = http://127.0.0.1:9001/api/auth/callback APP_URI = http://127.0.0.1:3000 -DB_URI = postgres://your_database_username:your_database_password@127.0.0.1:your_database_port/your_database_name -REDIS_URI = redis://127.0.0.1:6379 +DB_URI = postgres://your_database_username:your_database_password@your_postgres_host:your_database_port/your_database_name +REDIS_URI = redis://your_redis_host:6379 diff --git a/.env.production b/.env.production index f127cf2..a54f3b3 100644 --- a/.env.production +++ b/.env.production @@ -1,3 +1,5 @@ BASE_DOMAIN = domain.app REDIRECT_URI = https://backend.app/api/auth/callback APP_URI = https://frontend.app +DB_URI = postgres://your_database_username:your_database_password@your_postgres_host:your_database_port/your_database_name +REDIS_URI = redis://your_redis_host:6379 diff --git a/compose-core.yaml b/compose-core.yaml index 8bd9665..7360205 100644 --- a/compose-core.yaml +++ b/compose-core.yaml @@ -10,23 +10,24 @@ services: - postgres_data:/var/lib/postgresql/data user: postgres healthcheck: - test: ["CMD-SHELL", "pg_isready -U postgres -d spotify-manager"] + test: ["CMD-SHELL", 'psql -d spotify-manager -c "select version();"'] interval: 1s retries: 5 timeout: 5s redis: container_name: spotify-manager-redis - image: redis/redis-stack-server:latest + image: redis restart: on-failure volumes: - redis_data:/data + user: redis healthcheck: test: ["CMD-SHELL", "redis-cli ping | grep PONG"] interval: 1s retries: 5 timeout: 3s - web: - container_name: spotify-manager + api: + container_name: spotify-manager-api build: context: . init: true diff --git a/compose-dev.yaml b/compose-dev.yaml index 21b11cb..76eb6d1 100644 --- a/compose-dev.yaml +++ b/compose-dev.yaml @@ -1,5 +1,5 @@ services: - web: + api: environment: NODE_ENV: development env_file: diff --git a/compose-prod.yaml b/compose-prod.yaml index 3aab84b..6140b13 100644 --- a/compose-prod.yaml +++ b/compose-prod.yaml @@ -1,5 +1,5 @@ services: - web: + api: environment: NODE_ENV: production env_file: diff --git a/controllers/operations.ts b/controllers/operations.ts index 15d1c93..80a32c0 100644 --- a/controllers/operations.ts +++ b/controllers/operations.ts @@ -430,9 +430,9 @@ const _getPlaylistTracks: ( "playlist_snapshot:" + playlistID ); if (cachedSnapshotID === currentSnapshotID) { - const cachedTracksData = (await redisClient.json.get( - "playlist_tracks:" + playlistID - )) as _TrackObj[]; + const cachedTracksData = JSON.parse( + (await redisClient.get("playlist_tracks:" + playlistID)) ?? "[]" + ) as _TrackObj[]; return { tracks: cachedTracksData, snapshotID: cachedSnapshotID }; } let firstPageFields = ["tracks(next,items(is_local,track(uri)))"]; @@ -489,7 +489,10 @@ const _getPlaylistTracks: ( // cache new data await redisClient.set("playlist_snapshot:" + playlistID, currentSnapshotID); - await redisClient.json.set("playlist_tracks:" + playlistID, "$", pl.tracks); + await redisClient.set( + "playlist_tracks:" + playlistID, + JSON.stringify(pl.tracks) + ); return pl; }; diff --git a/package.json b/package.json index 5ecc557..3b7250f 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "bugs": { "url": "https://github.com/20kaushik02/spotify-manager/issues" }, - "homepage": "https://github.com/20kaushik02/spotify-manager#readme", + "homepage": "https://api.spotify-manager.knravish.me", "dependencies": { "axios": "^1.8.2", "bottleneck": "^2.19.5",