diff options
Diffstat (limited to 'src/types')
| -rw-r--r-- | src/types/index.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/types/index.ts b/src/types/index.ts index 5e0b2d4..89a2a6c 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -12,12 +12,27 @@ export interface NtfyConfig { topic?: string; } +export interface EmailConfig { + enabled: boolean; + to?: string; + from?: string; + host?: string; + port?: number; + secure?: boolean; + username?: string; + password?: string; + subject?: string; + includeBody?: boolean; + includeHeaders?: boolean; +} + export interface RouteConfig { name: string; contentType: ContentType; hcaptchaProtected: boolean; hcaptchaSecret?: string; ntfy?: NtfyConfig; + email?: EmailConfig; requireToken?: boolean; } @@ -71,6 +86,24 @@ export function isRouteConfig(obj: unknown): obj is RouteConfig { } } + // Validate email config if present + if (r.email !== undefined) { + if (typeof r.email !== 'object' || r.email === null) return false; + const email = r.email as Record<string, unknown>; + if (typeof email.enabled !== 'boolean') return false; + if (email.enabled && (typeof email.to !== 'string' || typeof email.from !== 'string')) { + return false; + } + if (email.host !== undefined && typeof email.host !== 'string') return false; + if (email.port !== undefined && typeof email.port !== 'number') return false; + if (email.secure !== undefined && typeof email.secure !== 'boolean') return false; + if (email.username !== undefined && typeof email.username !== 'string') return false; + if (email.password !== undefined && typeof email.password !== 'string') return false; + if (email.subject !== undefined && typeof email.subject !== 'string') return false; + if (email.includeBody !== undefined && typeof email.includeBody !== 'boolean') return false; + if (email.includeHeaders !== undefined && typeof email.includeHeaders !== 'boolean') return false; + } + // Validate requireToken if present if (r.requireToken !== undefined && typeof r.requireToken !== 'boolean') { return false; |
