import sql from "mssql";
import { validateEnv } from "../utils/envValidator.js";

const env = validateEnv(process.env);
export const sqlConfig: sql.config = {
    server: env.PROD_SERVER,
    database: `AlplaPROD_${env.PROD_PLANT_TOKEN}_cus`,
    user: env.PROD_USER,
    password: env.PROD_PASSWORD,
    options: {
        encrypt: true,
        trustServerCertificate: true,
    },
    requestTimeout: 90000, // in milliseconds
    pool: {
        max: 20, // Maximum number of connections in the pool
        min: 0, // Minimum number of connections in the pool
        idleTimeoutMillis: 10000, // How long a connection is allowed to be idle before being released
        reapIntervalMillis: 1000, // how often to check for idle resourses to destory
        acquireTimeoutMillis: 100000, // How long until a complete timeout happens
    },
};
