Blog
  • devcrisis
  • 🔮Software atoms
    • Validating code Architecture with dependency cruiser
    • Actionable ways to use ChatGPT
    • Most courses aren't worth it
    • SQLite is❤️
    • Stabilizing Tests without fixing them
    • Interviews should copy Advent of Code
    • Rust is nice
    • Agile fatigue is rising
    • Documentation is needed after all
    • The Direction of the JS ecosystem is good
    • Zero configuration == <3
    • Make small pull requests
    • Good practices fade out
    • Rushing !== unmaintainable
    • Commit message readability
    • Universal Practices
    • More functions == good
    • Mocking Private Functionality
    • Lines of code != feature count
    • Different Software - Different Quality
    • junior2mid
    • Book alternatives
    • Courses
    • Type Driven Development
    • Latest and Greatest
    • Real Developers
    • 10x Developer
    • Books for beginners 1
    • Parkinson's Law
    • nest-cli architecture is nice
    • Incremental Feature Delivery
    • Self Healing Software
      • Typed Configuration
  • 💡Memos
    • 2022 Holiday code report
    • Complexity
    • Software Development Fundamentals
  • 🧱foundation
    • Junior2Mid
    • Books and resources for new developers
    • 🏔️Now
Powered by GitBook
On this page
  1. Software atoms
  2. Self Healing Software

Typed Configuration

PreviousSelf Healing SoftwareNext2022 Holiday code report

Last updated 2 years ago

I've been down the configuration rabbithole.

I’ve noticed that most tools in the JS eco system (prettier, jest, eslint, etc) amongst other env formats support the config to be kept inside javascript files. (They basically support .js/.json and inside package.json)

I decided to test out how much benefits we can get if we store the (again, non secret) configuration per environment in the code.

I created a configuration type and for illustration a factory that returns the environment’s contents based on input.

Then I created 2 configuration files:

Since the exported variables were typed I got typehints and autocomplete where applicable.

The type errors are caught inside the editor and will be displayed when you try to run the app:

You can use additional types that will let you get a lot more out of the compiler, such as setting the range value of integers.

You can for inspiration for extra types.

Not sure how I feel about this. Further research required.

🔮
look here