blurts-server icon indicating copy to clipboard operation
blurts-server copied to clipboard

MNTOR-5089: Consolidate configuration settings

Open Vinnl opened this issue 3 weeks ago • 1 comments

References:

Jira: MNTOR-5089 Figma:

Description

This is a proposal for how to centralise our environment-specific configuration. If you both agree with this approach, I can do a sweep over the codebase for all references to process.env, and replace them by references to config.

One other thing we might consider is adopting @next/env instead of dotenv-flow - behaviour should be the same I think, but then we're using the exact same code Next.js is using to load env vars, so that's technically one fewer dependency, and less risk of divergence. (Plus, I'm not sure if dotenv-flow is being very actively maintained, and we need a fix there for the Next.js upgrade.)

How to test

I've included two examples where config are used:

  • On /admin/dev. To verify that this works, access that page with an admin account locally, then run using e.g. APP_ENV="production" npm run dev or by setting that in your .env.local, and verify that you now get a 404 on that page with the same account.
  • To verify that it also works in non-Next.js environments, I also added it to npm run dev:cron:monthly-activity-free. Likewise, if you set MONTHLY_ACTIVITY_FREE_EMAIL_BATCH_SIZE to a value other than 10, you should see that referenced in the logs:
{"level":"info","message":"Getting free subscribers with batch size: 10"}

Checklist (Definition of Done)

  • [x] Localization strings (if needed) have been added.
  • [x] Commits in this PR are minimal and have descriptive commit messages.
  • [x] I've added or updated the relevant sections in readme and/or code comments
  • [x] I've added a unit test to test for potential regressions of this bug.
  • [x] If this PR implements a feature flag or experimentation, I've checked that it still works with the flag both on, and with the flag off.
  • [x] If this PR implements a feature flag or experimentation, the Ship Behind Feature Flag status in Jira has been set
  • [ ] Product Owner accepted the User Story (demo of functionality completed) or waived the privilege.
  • [x] All acceptance criteria are met.
  • [x] Jira ticket has been updated (if needed) to match changes made during the development process.
  • [x] Jira ticket has been updated (if needed) with suggestions for QA when this PR is deployed to stage.

Vinnl avatar Dec 01 '25 14:12 Vinnl

Thanks @codemist. I'll probably start work on updating the rest to have something to work on, but I'll make sure not to merge it before your work, since conflicts are probably way easier for me to resolve (since my changes will basically all be the same change).

Vinnl avatar Dec 02 '25 10:12 Vinnl

Full PR applying this across the codebase at https://github.com/mozilla/blurts-server/pull/6350/.

Vinnl avatar Dec 15 '25 16:12 Vinnl