Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ COOKIE_SECRET=same-serious-secret
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000

# --- POSTGRES ---
DB_USERNAME=admin
DB_PASSWORD=p@ssword123
DB_DATABASE=task_tracker
DB_PORT=6000
DB_SCHEMA=base

# ВАЖНО:
Expand All @@ -24,6 +20,7 @@ DATABASE_URL=postgres://${DB_USERNAME}:${DB_PASSWORD}@localhost:${DB_PORT}/${DB_
# at development mode
REDIS_HOST=127.0.0.1
REDIS_PORT=7000
REDIS_PASSWORD=same-password

JWT_AUDIENCE="task-tracker-client"

Expand Down
6 changes: 2 additions & 4 deletions libs/config/src/config.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ export const ConfigSchema = z.object({
PORT: z.coerce.number().default(3000),
NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
COOKIE_SECRET: z.string({ error: 'COOKIE_SECRET is missing' }),
DB_USERNAME: z.string({ error: 'DB_USERNAME is missing' }),
DB_PASSWORD: z.string({ error: 'DB_PASSWORD is missing' }),
DB_DATABASE: z.string({ error: 'DB_DATABASE is missing' }),
DB_SCHEMA: z.string({ error: 'DB_SCHEMA is missing' }),
DATABASE_URL: z.string().url('DATABASE_URL must be a valid connection string'),
DATABASE_URL: z.string().nonempty('DATABASE_URL must be a valid connection string'),
REDIS_HOST: z.string().default('redis'),
REDIS_PORT: z.coerce.number().optional().default(6379),
REDIS_PASSWORD: z.string().optional(),
DOMAIN: z
.string()
.toLowerCase()
Expand Down
1 change: 1 addition & 0 deletions src/modules/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { ProjectsModule } from '../projects';
inject: [ConfigService],
useFactory: (cfg: ConfigService) => ({
connection: {
password: cfg.get('REDIS_PASSWORD'),
host: cfg.getOrThrow('REDIS_HOST'),
port: cfg.get('REDIS_PORT'),
},
Expand Down
2 changes: 2 additions & 0 deletions src/modules/auth/auth.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ const REPOSITORY = {
useFactory: async (cfg: ConfigService) => {
const host = cfg.getOrThrow('REDIS_HOST', { infer: true });
const port = cfg.get('REDIS_PORT');
const password = cfg.get('REDIS_PASSWORD');
const url = `redis://${host}${port ? `:${port}` : ''}`;

return {
type: 'single',
url,
options: {
password,
retryStrategy(times) {
return Math.min(times * 50, 2000);
},
Expand Down
2 changes: 2 additions & 0 deletions src/modules/teams/teams.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ const REPOSITORY = { provide: 'ITeamsRepository', useClass: TeamsRepository };
useFactory: async (cfg: ConfigService) => {
const host = cfg.getOrThrow('REDIS_HOST', { infer: true });
const port = cfg.get('REDIS_PORT');
const password = cfg.get('REDIS_PASSWORD');
const url = `redis://${host}${port ? `:${port}` : ''}`;

return {
type: 'single',
url,
options: {
password,
retryStrategy(times) {
return Math.min(times * 50, 2000);
},
Expand Down
Loading