amberframework / amber

A Crystal web framework that makes building applications fast, simple, and enjoyable. Get started with quick prototyping, less bugs, and blazing fast performance.
https://amberframework.org
MIT License
2.58k stars 206 forks source link

The New Config System! #1336

Open a-alhusaini opened 1 year ago

a-alhusaini commented 1 year ago

I am proud to anounce that the new config system has been created!

instead of using yml files all the configuration data will be stored in objects that are contained within Amber.environments! To change configuration variables for an environment you write

Amber.environments["production"].port = xyz

Or, if you need to add more functionality to your environment logic you can do the following

class MyEnvironment < Amber::DefaultConfig
  # your cusomizations go here
end
Amber.environments["development"] = MyEnvironment.new

All the values are stored in instance variables to ensure that all the logic for fetching them is run when the objects are instantiated. Catching configuration errors before the app starts!

This PR is blocked by the amber_cli package. We need to move to that package before changes to the amber new command can be implemented.