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

Improved configuration #148

Merged
merged 7 commits into from
Sep 24, 2022
Merged

Improved configuration #148

merged 7 commits into from
Sep 24, 2022

Conversation

tecc
Copy link
Member

@tecc tecc commented Sep 24, 2022

This change is mostly internal but does entail two user-facing change;

  • Created a new configuration section for file-based configurations: server.
  • Added server.useSecureCookies, which is the equivalent of COOKIE_SECURE.
  • For file configurations, baseUrl has been moved to server.baseUrl. See config/compatibility.yml

Internal changes:

  • Replaced last direct usages of getEnv, and marked the function as deprecated.
  • Create new system for using environment variables:
    • getEnvRaw is used to access the variables; it only gives you a string, and never anything else.
    • parseBool parses booleans from strings. true, 1, yes, and on are treated as true whilst false, 0, no, and off are treated as false.

getEnvRaw: `getEnvRaw` is essentially the same as `getEnv`, but much more safe as it doesn't automatically convert types - parsing is left to the consuming code.
parseBool: `parseBool` is a much more accepting function for parsing booleans. `true`, `1`, `yes`, and `on` are treated as `true`, and conversely, `false`, `0`, `no`, and `off` are treated as `false`.
proxyAttachments: `proxyAttachments` is the equivalent of `DIRECT_RESPONSE_ATTACHMENT`.
[...file].ts: Replaced direct usage of `getEnv` with new config system.
forcePathStyle: Added missing field of `forcePathStyle`.
proxyAttachments: Added documentation for `proxyAttachments`.
server: The `server` field will just contain things related to the server. I dunno how to explain it, but it's for that.
useSecureCookies: `server.useSecureCookies` is the equivalent of `COOKIE_SECURE`.
config/compatibility.yml: Add documentation for the new `server` field.
deprecation: Well, it is. `getEnv` is too direct. It's not really a good system.
config/compatibility.yml: Updated the example to reflect how the config actually works.
move-to-server: It feels nicer to have it inside the `server` field.
@tecc tecc merged commit 2542dc8 into main Sep 24, 2022
@tecc tecc deleted the change/better-config branch September 24, 2022 15:18
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