Create 'example' folder to speed up local development
Closed this issue · 2 comments
tl;dr
Create an example
folder that is its own self-contained app using @strong-config/node
to allow faster iteration during development.
The Problem
Currently, when we want to try out changes on real schemas or config files we have three options:
- Switch to another app that's already using
strong-config
such as our internalapi-gateway
- This is bad because it's tightly coupled with our own infra and external contributors don't have that option.
- It's also inconvenient in terms of DX to have to constantly switch between two repos just to try out some changes
- Rely solely on tests
- Obviously we should always write tests and our tests should be robus
- But sometimes you just want to try things out quickly, e.g. see how a certain code change affects the transformation of
schema.json
into TypeScript and always having to write a test for this is very cumbersome
- Create a new app that uses
@strong-config/node
- This is of course possible but also very repetitive
- Have to repeat various steps every time (e.g. create folder,
yarn init
,yarn add
, manually write schema file, config files...)
The Proposed Solution
Create an example
folder inside this repo that:
- Has one (or several) example
schema.json
to quickly try out how our code behaves in various scenarios - Has several example config files to quickly try out how our code behaves in various scenarios
In our package.json
, we will then create the following yarn tasks:
-
yarn dev:load $env
- Load a config file. Translate it into TypeScript. Log the result to the console. -
yarn dev:load:watch $env
- Same as above, but with hot-reloading on every file change vianodemon
-
yarn dev:validate $env
validates a config yaml against a schema -
yarn dev:validate:watch $env
- Same as above, but with hot-reloading on every file change vianodemon
- [BONUS]
yarn dev:encrypt $env
- Encrypts a config yaml - [BONUS]
yarn dev:decrypt $env
- Decrypts a config yaml
Sounds good! I wouldn't make it an entire node app though. Think something like
example/
/config
development.yaml
production.yaml
schema.json
is sufficient for now when I think about the development process. The rest we can control with yarn tasks:
yarn dev:load
: Useslib/index.js
as entry point and invokes theload
function onexample/
datayarn dev:validate
: Useslib/index.js
as entry point and invokes thevalidate
function onexample/
data- Future:
yarn dev:encrypt/decrypt/watch
as you suggested
Then for testing, it's very fast to break a config or the schema and call the yarn dev:*
commands again.
For me, the self-contained app makes much sense for a standalone @strong-config/example
porject though.
ok, sounds good, have updated the issue to reflect that we're starting with a simple example
folder that isn't a full node app