Enforcing that the keys in your environment variables configuration and mock configuration stay i...

Can I enforce that these 2 stay in sync? I want to have envVars from
.env
(that works), but mock coming from JSON, but enforce they stay in sync, e.g. I want it to yell at me right now on type level, because I have RESTATE_PORT and STATE_PORT.

import { Config, ConfigProvider, Layer } from 'effect'

export const envVars = Config.all({
  SERVER_PORT: Config.integer('SERVER_PORT'),
  JOBS_TABLE: Config.string('JOBS_TABLE').pipe(
    Config.withDefault('jobs-table'),
  ),
  LOG_LEVEL: Config.string('LOG_LEVEL').pipe(Config.withDefault('info')),
  RESTATE_PORT: Config.integer('RESTATE_PORT'),
})

const mockConfigProvider = ConfigProvider.fromJson({
  SERVER_PORT: 3001,
  JOBS_TABLE: 'jobs-table-test',
  LOG_LEVEL: 'debug',
  STATE_PORT: 9997,
})

export const MockConfigLayer = Layer.setConfigProvider(mockConfigProvider)
Was this page helpful?