Skip to content

TaskView is a self-hosted project and task management platform focused on clarity, ownership, and control. TaskView is built for teams that want a transparent, self-hosted alternative to SaaS task managers.

2.7 KB
Raw Blame
import { z } from 'zod';

export const AppEnvSchema = z.object({
    LIC_PASSWORD: z.string().optional(),
    DB_HOST: z.string(),
    DB_USER: z.string(),
    DB_PASSWORD: z.string(),
    DB_NAME: z.string(),
    DB_PORT: z.string(),
    APP_PORT: z.string(),
    JWT_ALG: z.string(),
    JWT_SIGN: z.string(),

    ACCESS_LIFE_TIME: z.string(),
    REFRESH_LIFE_TIME: z.string(),

    SMTP_HOST: z.string().optional(),
    SMTP_PORT: z.string().optional(),
    SMTP_USERNAME: z.string().optional(),
    SMTP_PASSWORD: z.string().optional(),
    SMTP_ENCRYPTION: z.string().optional(),
    SMTP_FROM_NAME: z.string().optional(),
    SMTP_FROM_EMAIL: z.string().optional(),
    APP_URL: z.string(),

    // Send an email to a person when they are invited to a project (requires SMTP); default off
    INVITE_EMAIL_ENABLED: z.string().optional(),
    // Max invite emails one user may trigger per hour (default 30)
    INVITE_EMAIL_HOURLY_LIMIT: z.string().optional(),

    // Max login codes one account may request by email per hour (default 5)
    LOGIN_CODE_HOURLY_LIMIT: z.string().optional(),

    // Days a sign-in session lasts, however often its tokens are refreshed (default 90)
    SESSION_MAX_AGE_DAYS: z.string().optional(),

    // Let users delete their own account (default false)
    ALLOW_ACCOUNT_DELETION: z.string().optional(),

    // Allow outgoing webhooks to target loopback/private/link-local addresses (default off, see SSRF)
    WEBHOOKS_ALLOW_PRIVATE_URLS: z.string().optional(),

    // How account password changes are confirmed: code sent by email (default) or current password
    PASSWORD_CHANGE_CONFIRMATION: z.enum(['email', 'password']).optional(),

    // Comma-separated list of enabled login methods (magic-link, password, sso, social); unset = all enabled
    AUTH_LOGIN_METHODS: z.string().optional(),

    TELEGRAM_BOT_TOKEN: z.string().optional(),
    TELEGRAM_BOT_USERNAME: z.string().optional(),
    TELEGRAM_WEBHOOK_SECRET: z.string().optional(),

    SLACK_CLIENT_ID: z.string().optional(),
    SLACK_CLIENT_SECRET: z.string().optional(),
    SLACK_CALLBACK_URL: z.string().optional(),
    SLACK_SIGNING_SECRET: z.string().optional(),
});

export const StringToNumber = z
    .union([z.string(), z.number()])
    .transform((value) => Number(value))
    .refine((val) => !isNaN(val), { message: 'Invalid number' });

export const StringToNumberOrNull = z
    .union([z.string(), z.number(), z.null()])
    .transform((value) => (value === null ? null : Number(value)))
    .refine((val) => val === null || !isNaN(val), { message: 'Invalid number' });

export const LicTypeScheme = z.object({
    version: z.string(),
    features: z.string(),
    owner: z.string().email(),
    company: z.string(),
});