Skip to main content

βš™οΈ Default Config

Welcome! This step-by-step guide will show you how to create a default config for your schema to make deploying your service an absolute breeze. πŸš€

🧠 Assumptions​

This guide assumes you already understand how to create schemas and have one ready for your service. Haven't created a schema yet? No problem! Stop here and check out the Zero to Hero guide first.

Note: The examples below use the my-schema (version v1) created in the Zero to Hero guide.

πŸ› οΈ Create Your Default Config​

1. Create the File
Create a new file named v1.configs.json in the exact same folder as your schema file.

schemas/my-domain/my-schema/v1.configs.json
[]

2. Name Your Config
Choose a clear, descriptive name for your default configuration.

schemas/my-domain/my-schema/v1.configs.json
[
{
"name": "default-config",
"value": {}
}
]

3. Populate the Values
Add the default values that align perfectly with your schema properties!

schemas/my-domain/my-schema/v1.configs.json
[
{
"name": "default-config",
"value": {
"id": "default-id",
"name": "default-name",
"age": 18,
"isAlive": true
}
}
]

βœ… Run Validations​

Always validate your work to ensure the default config is perfectly formatted! Run the validation script:

npm run validate

πŸ”— Add a Reference to Another Config​

Need to dry up your code? If your default config relies on a reference to another config or a shared common config, you can easily reference it directly in the value object:

schemas/my-domain/my-schema/v1.configs.json
[
{
"name": "default-config",
"value": {
"commonConfig": {
"$ref": {
"configName": "other-config",
"version": "latest"
}
}
}
}
]

πŸš€ Next Steps​

Boom! You are done writing your default config. πŸŽ‰

  1. Submit a PR to the schemas repo and request a review from the team.
  2. Need Help? Don't hesitate to reach out if you get stuck.
  3. Have Ideas? If you have suggestions to improve this guide, please open a pull request!