good forst commit
This commit is contained in:
@@ -48,13 +48,23 @@ describe('validateEnv', () => {
|
||||
expect(result.WHATSAPP_SESSION_PATH).toBe('./sessions');
|
||||
});
|
||||
|
||||
it('applies default TOWER_ADMIN_JIDS of empty string when not set', () => {
|
||||
it('applies default TOWER_PORTAL_BASE_URL of http://localhost:3000 when not set', () => {
|
||||
const env = {
|
||||
DATABASE_URL: 'postgresql://user:pass@localhost:5432/db',
|
||||
REDIS_URL: 'redis://localhost:6379',
|
||||
JWT_SECRET: 'a'.repeat(32),
|
||||
};
|
||||
const result = validateEnv(env as NodeJS.ProcessEnv);
|
||||
expect(result.TOWER_ADMIN_JIDS).toBe('');
|
||||
expect(result.TOWER_PORTAL_BASE_URL).toBe('http://localhost:3000');
|
||||
});
|
||||
|
||||
it('applies default MEMBER_JWT_EXPIRES_IN of 30d when not set', () => {
|
||||
const env = {
|
||||
DATABASE_URL: 'postgresql://user:pass@localhost:5432/db',
|
||||
REDIS_URL: 'redis://localhost:6379',
|
||||
JWT_SECRET: 'a'.repeat(32),
|
||||
};
|
||||
const result = validateEnv(env as NodeJS.ProcessEnv);
|
||||
expect(result.MEMBER_JWT_EXPIRES_IN).toBe('30d');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -10,7 +10,10 @@ const envSchema = z.object({
|
||||
MEILI_MASTER_KEY: z.string().default('tower_meili_dev_key'),
|
||||
LOG_LEVEL: z.enum(['trace', 'debug', 'info', 'warn', 'error']).default('info'),
|
||||
WHATSAPP_SESSION_PATH: z.string().default('./sessions'),
|
||||
TOWER_ADMIN_JIDS: z.string().default(''),
|
||||
TOWER_PORTAL_BASE_URL: z.string().url().default('http://localhost:3000'),
|
||||
BCRYPT_ROUNDS: z.coerce.number().int().min(4).max(15).default(10),
|
||||
JWT_EXPIRES_IN: z.string().default('7d'),
|
||||
MEMBER_JWT_EXPIRES_IN: z.string().default('30d'),
|
||||
});
|
||||
|
||||
export type Env = z.infer<typeof envSchema>;
|
||||
|
||||
Reference in New Issue
Block a user