import { transformCase } from '@priestine/case-transformer';
import { fromEnv } from '../utils/from-env.util';
import ProcessEnv = NodeJS.ProcessEnv;

export function updateConfigFromEnv(env: ProcessEnv) {
  return ({ intermediate }: SemanticsCtx) => {
    Object.keys(intermediate).forEach((key) => {
      const envKey = transformCase(key)
        .from.camel.to.snake.toString()
        .toUpperCase();
      const getFromEnv = fromEnv(env);

      if (typeof intermediate[key] === 'number') {
        intermediate[key] = Number.isInteger(intermediate[key])