const { cleanEnv, str, num, url } = require('envalid');

const validateEnv = () => {
  cleanEnv(process.env, {
    NODE_ENV: str({ choices: ['development', 'test', 'production'] }),
    PORT: num({ default: 3000 }),
    DATABASE_URL: url(),
    REDIS_URL: url(),
    ACCESS_TOKEN_SECRET: str(),
    REFRESH_TOKEN_SECRET: str(),
    ACCESS_TOKEN_EXPIRES_IN: str(),
    REFRESH_TOKEN_EXPIRES_IN: str(),
    RATE_LIMIT_WINDOW_MS: num(),
    RATE_LIMIT_MAX_REQUESTS: num(),
    ALLOWED_ORIGINS: str()
  });
};

module.exports = { validateEnv };