63 lines
No EOL
1.9 KiB
TypeScript
63 lines
No EOL
1.9 KiB
TypeScript
import { z } from 'zod';
|
|
|
|
// Common service configuration
|
|
export const serviceConfigSchema = z.object({
|
|
name: z.string(),
|
|
port: z.number().min(1).max(65535),
|
|
host: z.string().default('0.0.0.0'),
|
|
healthCheckPath: z.string().default('/health'),
|
|
metricsPath: z.string().default('/metrics'),
|
|
shutdownTimeout: z.number().default(30000),
|
|
cors: z.object({
|
|
enabled: z.boolean().default(true),
|
|
origin: z.union([z.string(), z.array(z.string())]).default('*'),
|
|
credentials: z.boolean().default(true),
|
|
}).default({}),
|
|
});
|
|
|
|
// Logging configuration
|
|
export const loggingConfigSchema = z.object({
|
|
level: z.enum(['trace', 'debug', 'info', 'warn', 'error', 'fatal']).default('info'),
|
|
format: z.enum(['json', 'pretty']).default('json'),
|
|
loki: z.object({
|
|
enabled: z.boolean().default(false),
|
|
host: z.string().default('localhost'),
|
|
port: z.number().default(3100),
|
|
labels: z.record(z.string()).default({}),
|
|
}).optional(),
|
|
});
|
|
|
|
// Queue configuration
|
|
export const queueConfigSchema = z.object({
|
|
redis: z.object({
|
|
host: z.string().default('localhost'),
|
|
port: z.number().default(6379),
|
|
password: z.string().optional(),
|
|
db: z.number().default(1),
|
|
}),
|
|
defaultJobOptions: z.object({
|
|
attempts: z.number().default(3),
|
|
backoff: z.object({
|
|
type: z.enum(['exponential', 'fixed']).default('exponential'),
|
|
delay: z.number().default(1000),
|
|
}).default({}),
|
|
removeOnComplete: z.boolean().default(true),
|
|
removeOnFail: z.boolean().default(false),
|
|
}).default({}),
|
|
});
|
|
|
|
// HTTP client configuration
|
|
export const httpConfigSchema = z.object({
|
|
timeout: z.number().default(30000),
|
|
retries: z.number().default(3),
|
|
retryDelay: z.number().default(1000),
|
|
userAgent: z.string().optional(),
|
|
proxy: z.object({
|
|
enabled: z.boolean().default(false),
|
|
url: z.string().url().optional(),
|
|
auth: z.object({
|
|
username: z.string(),
|
|
password: z.string(),
|
|
}).optional(),
|
|
}).optional(),
|
|
}); |