feat(config): respect REDIS_DB env var for queue and transmit

Allow operators to select a Redis logical database index via the
REDIS_DB environment variable. Without this, the BullMQ queue and the
@adonisjs/transmit Redis transport both implicitly used db 0, causing
key collisions when sharing a Redis instance across multiple services
or environments.

REDIS_DB is added to the env schema as an optional number; both
config/queue.ts and config/transmit.ts fall back to db 0 when unset,
preserving existing behavior.
This commit is contained in:
John Onysko 2026-05-24 14:20:17 -04:00 committed by jakeaturner
parent e1c7435fc4
commit f553a0d57d
No known key found for this signature in database
GPG Key ID: B1072EBDEECE328D
4 changed files with 6 additions and 0 deletions

View File

@ -12,6 +12,9 @@ DB_PASSWORD=password
DB_SSL=false
REDIS_HOST=localhost
REDIS_PORT=6379
# Optional: Redis logical database index (0-15). Defaults to 0 if unset.
# Set this when sharing a Redis instance across services to avoid key collisions.
# REDIS_DB=0
# Storage path for NOMAD content (ZIM files, maps, etc.)
# On Windows dev, use an absolute path like: C:/nomad-storage
# On Linux production, use: /opt/project-nomad/storage

View File

@ -4,6 +4,7 @@ const queueConfig = {
connection: {
host: env.get('REDIS_HOST'),
port: env.get('REDIS_PORT') ?? 6379,
db: env.get('REDIS_DB') ?? 0,
},
}

View File

@ -8,6 +8,7 @@ export default defineConfig({
driver: redis({
host: env.get('REDIS_HOST'),
port: env.get('REDIS_PORT'),
db: env.get('REDIS_DB') ?? 0,
keyPrefix: 'transmit:',
})
}

View File

@ -54,6 +54,7 @@ export default await Env.create(new URL('../', import.meta.url), {
*/
REDIS_HOST: Env.schema.string({ format: 'host' }),
REDIS_PORT: Env.schema.number(),
REDIS_DB: Env.schema.number.optional(),
/*
|----------------------------------------------------------