(answers: SetupAnswers)
| 246 | } |
| 247 | } |
| 248 | export function validatePortNumbers(answers: SetupAnswers): void { |
| 249 | const portFields: SetupKey[] = [ |
| 250 | "API_PORT", |
| 251 | "API_MINIO_PORT", |
| 252 | "API_POSTGRES_PORT", |
| 253 | "CLOUDBEAVER_MAPPED_PORT", |
| 254 | "MINIO_API_MAPPED_PORT", |
| 255 | "MINIO_CONSOLE_MAPPED_PORT", |
| 256 | "POSTGRES_MAPPED_PORT", |
| 257 | "CADDY_HTTP_MAPPED_PORT", |
| 258 | "CADDY_HTTPS_MAPPED_PORT", |
| 259 | "CADDY_HTTP3_MAPPED_PORT", |
| 260 | "CADDY_TALAWA_API_PORT", |
| 261 | ]; |
| 262 | const invalidFields: string[] = []; |
| 263 | for (const field of portFields) { |
| 264 | const value = answers[field]; |
| 265 | if (value !== undefined) { |
| 266 | const port = Number.parseInt(value, 10); |
| 267 | if (Number.isNaN(port) || port < 1 || port > 65535) { |
| 268 | invalidFields.push(field); |
| 269 | } |
| 270 | } |
| 271 | } |
| 272 | if (invalidFields.length > 0) { |
| 273 | throw new Error( |
| 274 | `Port numbers must be between 1 and 65535: ${invalidFields.join(", ")}`, |
| 275 | ); |
| 276 | } |
| 277 | } |
| 278 | export function validateSamplingRatio(input: string): true | string { |
| 279 | const ratio = Number.parseFloat(input); |
| 280 | if (Number.isNaN(ratio) || ratio < 0 || ratio > 1) { |
no outgoing calls
no test coverage detected