forked from AgesEmpire/StellarSwipe-Backends
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify-config.ts
More file actions
52 lines (45 loc) · 1.46 KB
/
Copy pathverify-config.ts
File metadata and controls
52 lines (45 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { configSchema } from './src/config/schemas/config.schema';
function validate(env: any) {
const { error } = configSchema.validate(env, { abortEarly: false, allowUnknown: true });
if (error) {
console.error('Validation failed:', error.details.map(d => d.message).join(', '));
return false;
}
console.log('Validation successful!');
return true;
}
const validDevEnv = {
NODE_ENV: 'development',
PORT: 3000,
DATABASE_HOST: 'localhost',
DATABASE_PORT: 5432,
DATABASE_USER: 'postgres',
DATABASE_PASSWORD: 'password',
DATABASE_NAME: 'stellarswipe',
REDIS_HOST: 'localhost',
REDIS_PORT: 6379,
STELLAR_NETWORK: 'testnet',
STELLAR_HORIZON_URL: 'https://horizon-testnet.stellar.org',
STELLAR_SOROBAN_RPC_URL: 'https://soroban-testnet.stellar.org',
STELLAR_NETWORK_PASSPHRASE: 'Test SDF Network ; September 2015',
JWT_SECRET: 'a'.repeat(32),
XAI_API_KEY: 'test-key'
};
const validMainnetEnv = {
...validDevEnv,
NODE_ENV: 'mainnet',
STELLAR_NETWORK: 'public',
STELLAR_HORIZON_URL: 'https://horizon.stellar.org',
STELLAR_SOROBAN_RPC_URL: 'https://soroban-rpc.stellar.org',
STELLAR_NETWORK_PASSPHRASE: 'Public Global Stellar Network ; September 2015',
};
const invalidEnv = {
NODE_ENV: 'invalid', // should fail
// missing required fields
};
console.log('Testing Valid Dev Env:');
validate(validDevEnv);
console.log('\nTesting Valid Mainnet Env:');
validate(validMainnetEnv);
console.log('\nTesting Invalid Env:');
validate(invalidEnv);