forked from StellarStream-HQ/StellarStream
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.ts
More file actions
81 lines (71 loc) · 1.83 KB
/
Copy pathconfig.ts
File metadata and controls
81 lines (71 loc) · 1.83 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import dotenv from 'dotenv';
import { z } from 'zod';
dotenv.config();
/**
* Configuration Schema for the StellarStream Backend/Watcher.
* Uses Zod for runtime validation and type inference.
*/
const envSchema = z.object({
/**
* The URL of the Stellar/Soroban RPC endpoint.
* @example "https://soroban-testnet.stellar.org"
*/
STELLAR_RPC_URL: z.string().url({ message: "STELLAR_RPC_URL must be a valid URL." }),
/**
* The network passphrase for the target Stellar network.
* Defaults to Testnet if not provided.
*/
STELLAR_NETWORK_PASSPHRASE: z
.string()
.default("Test SDF Network ; September 2015"),
/**
* The ID of the StellarStream smart contract (C...).
* Must be a 56-character string starting with 'C'.
*/
CONTRACT_ID: z
.string()
.length(56, "CONTRACT_ID must be exactly 56 characters.")
.startsWith("C", "CONTRACT_ID must start with 'C'."),
/**
* Frequency of polling the RPC for new events in milliseconds.
* @default 5000
*/
POLL_INTERVAL_MS: z.coerce
.number()
.int()
.positive()
.default(5000),
/**
* Maximum number of retry attempts for transient RPC failures.
* @default 3
*/
MAX_RETRIES: z.coerce
.number()
.int()
.min(0)
.default(3),
/**
* Initial delay for exponential backoff in milliseconds.
* @default 2000
*/
RETRY_DELAY_MS: z.coerce
.number()
.int()
.min(0)
.default(2000),
/**
* Number of ledgers to stay behind the tip for safety against reorgs.
* @default 10
*/
SAFETY_MARGIN: z.coerce
.number()
.int()
.min(0)
.default(10),
});
/**
* Validated configuration object.
* All services should import this object rather than accessing process.env directly.
*/
export const config = envSchema.parse(process.env);
export type Config = z.infer<typeof envSchema>;