Skip to main content

Practice ยท 2 of 2

Typed Config Loader

Write loadConfig(env) that converts raw env strings into a typed config object: port (number, default 3000 when absent), databaseUrl (string), debug (boolean โ€” true only for exactly the string "true"), and features (array from a comma-separated FEATURES value; absent => []). Throw on a non-numeric PORT rather than silently defaulting.

Difficulty: advanced

Back to lesson: Practice: Environment Configuration โ€” Practice