Repository navigation
feat: secure redis env config for VPS - #75
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR introduces a more VPS/open-source-friendly configuration approach by allowing keywords to be sourced from environment variables (instead of a committed JSON file) and adds an optional Redis-backed cache implementation for job search caching.
Changes:
- Add
KEYWORDS_STORAGE_MODE=env|fileto control whether keywords are read/written viaSEARCH_KEYWORDSenv var orbackend/src/db/environment.json. - Introduce a Redis cache implementation (fallbacks to in-memory) and update the cache call sites to support async cache operations.
- Update docs, docker-compose defaults,
.env.example, and add/adjust unit + integration tests.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents safer VPS config guidance for Redis/Postgres + env-based keywords |
| docker-compose.yml | Adds env defaults for keywords mode and cache-related env vars |
| backend/.env.example | Adds examples for KEYWORDS_STORAGE_MODE, Redis, DB, TTL, prefix |
| backend/package.json | Adds redis dependency |
| package-lock.json | Locks redis and its transitive deps |
| backend/src/config.js | Adds keywords storage mode logic + new env-derived config fields |
| backend/src/jobsApiApp.js | Supports env-mode keyword read/write for /api/keywords |
| backend/src/cache/cache.js | Adds RedisCache with memory fallback and lazy client init |
| backend/src/pipeline/searchJobsWithCache.js | Awaits cache operations for Redis compatibility |
| backend/tests/unit/utils/config.test.js | Adds coverage for env-mode priority behavior |
| backend/tests/integration/jobsApi.test.js | Adds coverage for /api/keywords behavior in env mode |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -63,20 +92,15 @@ function parseKeywords(value) { | |||
| return normalizeKeywords(data.KEYWORDS) ?? []; | |||
| } | |||
| } | |||
| } catch (err) { | |||
| } catch { | |||
There was a problem hiding this comment.
parseKeywords() ainda tenta ler environment.json mesmo quando KEYWORDS_STORAGE_MODE=env se SEARCH_KEYWORDS estiver vazio/undefined (porque parseKeywordsFromEnv retorna null e o fluxo cai no bloco do arquivo). Isso contradiz o comportamento em jobsApiApp.readEnvironmentData() (que, em modo env, nunca consulta arquivo) e pode reintroduzir dependência do JSON em produção. Ajuste sugerido: em modo env, não ler arquivo; faça fallback direto para DEFAULT_KEYWORDS (ou [], conforme regra desejada) quando SEARCH_KEYWORDS não tiver valores.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Benevanio <benevaniosantos930@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Benevanio <benevaniosantos930@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Benevanio <benevaniosantos930@gmail.com>
…obs_Scraper_Global into feature/redis-config # Conflicts: # backend/src/jobsApiApp.js
…st related configurations
No description provided.