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: Configuration checking on backend startup, and via cli. #203

Merged
merged 6 commits into from
Sep 25, 2024

Conversation

jamesread
Copy link
Collaborator

@jamesread jamesread commented Sep 6, 2024

What kind of change does this PR introduce?

This PR introduces a new feature, to check configuration (provided by the .env file) for values that could cause issues. Some of these issues have been hit in the last few days by looking at Discord support requests, including, but not limited to;

  • "redis://" being missed in the REDIS URL
  • People not understanding why they're not getting emails (RESEND_API_KEY)
  • CloudFlare R2 is required for provider configuration (CLOUDFLARE_ varialbes) - I hit this myself.
  • _URL variables having a trailing /, causing CORS to fail - I hit this issue myself.

I thought it useful to run this configuration check on startup of the backend service (here shown with the default unchanged env file - hence lots of warnings);

[Nest] 1483725  - 06/09/2024, 23:40:46    WARN [Configuration issue] REDIS_URL not set
[Nest] 1483725  - 06/09/2024, 23:40:46    WARN [Configuration issue] REDIS_URL is not a valid URL
[Nest] 1483725  - 06/09/2024, 23:40:46    WARN [Configuration issue] JWT_SECRET not set.
[Nest] 1483725  - 06/09/2024, 23:40:46    WARN [Configuration issue] MAIN_URL not set.
[Nest] 1483725  - 06/09/2024, 23:40:46    WARN [Configuration issue] FRONTEND_URL not set.
[Nest] 1483725  - 06/09/2024, 23:40:46    WARN [Configuration issue] NEXT_PUBLIC_BACKEND_URL not set.
[Nest] 1483725  - 06/09/2024, 23:40:46    WARN [Configuration issue] BACKEND_INTERNAL_URL not set.
[Nest] 1483725  - 06/09/2024, 23:40:46    WARN [Configuration issue] RESEND_API_KEY not set. Needed to send user activation emails.
[Nest] 1483725  - 06/09/2024, 23:40:46    WARN [Configuration issue] CLOUDFLARE_ACCOUNT_ID not set. Needed to setup providers.
[Nest] 1483725  - 06/09/2024, 23:40:46    WARN [Configuration issue] CLOUDFLARE_ACCESS_KEY not set. Needed to setup providers.
[Nest] 1483725  - 06/09/2024, 23:40:46    WARN [Configuration issue] CLOUDFLARE_SECRET_ACCESS_KEY not set. Needed to setup providers.
[Nest] 1483725  - 06/09/2024, 23:40:46    WARN [Configuration issue] CLOUDFLARE_BUCKETNAME not set. Needed to setup providers.
[Nest] 1483725  - 06/09/2024, 23:40:46    WARN [Configuration issue] CLOUDFLARE_BUCKET_URL not set. Needed to setup providers.
[Nest] 1483725  - 06/09/2024, 23:40:46    WARN [Configuration issue] CLOUDFLARE_REGION not set. Needed to setup providers.
[Nest] 1483725  - 06/09/2024, 23:40:46    WARN Configuration issues found: 14. You can run `npm run command config:check` to quickly check again.
[Nest] 1483725  - 06/09/2024, 23:40:46     LOG 🚀 Application is running on: http://localhost:3000

As the log message above says, the check can also be triggered via cli, by doing npm run command config:check;

> nx run commands:command:development config:check

Configuration issue: REDIS_URL not set
Configuration issue: REDIS_URL is not a valid URL
Configuration issue: JWT_SECRET not set.
Configuration issue: MAIN_URL not set.
Configuration issue: FRONTEND_URL not set.
Configuration issue: NEXT_PUBLIC_BACKEND_URL not set.
Configuration issue: BACKEND_INTERNAL_URL not set.
Configuration issue: RESEND_API_KEY not set. Needed to send user activation emails.
Configuration issue: CLOUDFLARE_ACCOUNT_ID not set. Needed to setup providers.
Configuration issue: CLOUDFLARE_ACCESS_KEY not set. Needed to setup providers.
Configuration issue: CLOUDFLARE_SECRET_ACCESS_KEY not set. Needed to setup providers.
Configuration issue: CLOUDFLARE_BUCKETNAME not set. Needed to setup providers.
Configuration issue: CLOUDFLARE_BUCKET_URL not set. Needed to setup providers.
Configuration issue: CLOUDFLARE_REGION not set. Needed to setup providers.
Configuration check complete, issues:  14
Press Ctrl+C to exit.

Why was this change needed?

My hope is to help smooth the onboarding experience for new users, resulting in less support requests by configuration checking.

Other information;

This is my first Typescript / NextJS / NX and similar PR! I'm not used to this toolchain, so I'm not quite sure what is idiomatic yet. I did run eslint against these changes and didn't see anything reported.

I'm "xconspirisist" on Discord, we discussed this in the #dev-support channel before, so I'm hoping this is well received!

Copy link

vercel bot commented Sep 6, 2024

@jamesread is attempting to deploy a commit to the Listinai Team on Vercel.

A member of the Team first needs to authorize it.

@jamesread jamesread merged commit d25a33e into gitroomhq:main Sep 25, 2024
6 of 8 checks passed
@jamesread jamesread deleted the configuration-checking branch September 25, 2024 23:15
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