Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(parser): allow to customize interpolation of value #34

Closed
wants to merge 1 commit into from

Conversation

RomainLanz
Copy link
Member

@RomainLanz RomainLanz commented Nov 14, 2023

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.

  1. 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
  1. You may encrypt your secrets. You will be able to decrypt them on the fly.
APP_KEY=encrypted:ksadskjadsjkdasjkdsjdjaskjkdjkasdkj

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.

@RomainLanz
Copy link
Member Author

After a discussion internally, we are closing this PR. A new one will be published with a better DX. ✌🏼

@RomainLanz RomainLanz closed this Nov 16, 2023
@RomainLanz RomainLanz deleted the feat/read-value-custom-hook branch March 30, 2024 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant