This PR adds a way to set up a custom hook, helping to interpolate the value of your env.
It can be useful in multiple scenarios.
To manage your secrets, you may use a Secrets Vault like Docker Secret or HashiCorp Vault. Doing so it will generate a path for your secret and won't give you any value directly. You can write a custom logic to read the file content.
DB_PASSWORD=file:/run/secrets/db_password
You may encrypt your secrets. You will be able to decrypt them on the fly.
In user-land, they will be able to pass an option to their Env.create() call.
Env.create(new URL('../', import.meta.url), {
....
}, {
async onVariableRead(key, value) {
if (value.startWidth('file:') {
// read from file...
}
return value
}
})
I am unsure if passing the key to the custom hook is useful. Also, if we do, I don't know if the value should be the first argument since people will often use it and disregard the env key.
Hey there! 👋🏻
This PR adds a way to set up a custom hook, helping to interpolate the value of your env.
It can be useful in multiple scenarios.
To manage your secrets, you may use a Secrets Vault like
Docker Secret
orHashiCorp Vault
. Doing so it will generate a path for your secret and won't give you any value directly. You can write a custom logic to read the file content.You may encrypt your secrets. You will be able to decrypt them on the fly.
In user-land, they will be able to pass an option to their
Env.create()
call.I am unsure if passing the
key
to the custom hook is useful. Also, if we do, I don't know if thevalue
should be the first argument since people will often use it and disregard the env key.