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

Eagerly load, but lazily fail environment variables on startup #641

Merged
merged 10 commits into from
Apr 7, 2025

Conversation

jnatten
Copy link
Contributor

@jnatten jnatten commented Apr 4, 2025

Har hatt lyst til å gjøre noe som ligner på dette før, men ikke følt verdien var verdt omskrivingen før @katrinewi fikk problemer med å kjøre type genereringen lokalt pga en tullete manglende variabel.

Denne lar oss kræsje applikasjonene på oppstart dersom påkrevde variabler mangler, men fremdeles ikke kræsje med --save-swagger flagget.

Infører ny Prop klasse istedenfor å hente en string med en gang vi kaller prop.
Når vi treffer et prop kall så forsøker vi å laste prop'en og lagrer resultatet i en Prop klasse.

Denne klassen brukes så igjen senere til å sjekke om prop'en ble lastet inn riktig eller ikke fantes.

jnatten added 4 commits April 3, 2025 13:49
This is so we can run the type generation script without the setup.
Makes it easier to run the type generation locally without setting up a
bunch of needless variables.

This does however make detecting missing environment variables less
likely at startup. We should look into how we can make those detected at
startup, but not when using `--save-swagger` arguments.
This patch introduces a abstraction called `Prop` which we use to load
required properties. These will be loaded eagerly so we can crash on
startup if they are missing. But they also allow us to run parts of the
project without them.

Allows us to run applications with `--save-swagger` argument without
variables that isn't required until runtime.
This should allow us to use dependencies from `common` in
`scalatestsuite` while keeping the base suite available for `common`
itself.
@jnatten jnatten force-pushed the environmentless-typescript-generation branch from 585cb9e to 06384a2 Compare April 4, 2025 05:41
Caused more trouble than it was worth with this implementation. Might be
worth it to revisit in the future.
@jnatten jnatten force-pushed the environmentless-typescript-generation branch 4 times, most recently from 0e4b14e to 09e6ad3 Compare April 4, 2025 08:28
@jnatten jnatten force-pushed the environmentless-typescript-generation branch from 09e6ad3 to 62e5f79 Compare April 4, 2025 09:45
@jnatten jnatten requested a review from a team April 4, 2025 09:58
I would argue slightly more readable and extendable
Copy link
Member

@gunnarvelle gunnarvelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

@jnatten jnatten merged commit 9b83cb3 into master Apr 7, 2025
37 checks passed
@jnatten jnatten deleted the environmentless-typescript-generation branch April 7, 2025 04:34
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.

2 participants