-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add ConfigModule startup validation with Joi schema #118
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e8d3a24
feat: switch auth tokens to httpOnly cookies
GitAddRemote 4fdd24d
feat: add ConfigModule startup validation with Joi schema
GitAddRemote 008fedc
fix: update CI env vars and migrate E2E tests to cookie auth
GitAddRemote 5444339
fix: address review comments on env validation and auth cookie handling
GitAddRemote 89b0c51
fix: read PORT as number to ensure valid TCP port for app.listen
GitAddRemote 5d15684
fix: address PR118 review comments
GitAddRemote 5b731fd
fix: remove JWT_REFRESH_SECRET from env example and test env
GitAddRemote a8b865d
fix: address PR118 review comments — Joi production guards, ConfigSer…
GitAddRemote 58aea71
fix: correct Joi.default() usage and add ConfigService to auth unit test
GitAddRemote 91537c5
chore: merge main into feature/ISSUE-97-configmodule-validation
GitAddRemote File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import * as Joi from 'joi'; | ||
|
|
||
| export const envValidationSchema = Joi.object({ | ||
| // Application | ||
| NODE_ENV: Joi.string() | ||
| .valid('development', 'production', 'test') | ||
| .default('development'), | ||
| PORT: Joi.number().default(3001), | ||
| APP_NAME: Joi.string().default('STATION BACKEND'), | ||
|
|
||
| // JWT | ||
| JWT_SECRET: Joi.string().min(32).required(), | ||
|
|
||
|
GitAddRemote marked this conversation as resolved.
GitAddRemote marked this conversation as resolved.
|
||
| // Database | ||
| DATABASE_HOST: Joi.string().required(), | ||
| DATABASE_PORT: Joi.number().default(5433), | ||
| DATABASE_USER: Joi.string().required(), | ||
| DATABASE_PASSWORD: Joi.string().required(), | ||
| DATABASE_NAME: Joi.string().required(), | ||
|
|
||
| // Redis | ||
| REDIS_HOST: Joi.string().default('localhost'), | ||
| REDIS_PORT: Joi.number().default(6379), | ||
| USE_REDIS_CACHE: Joi.string().valid('true', 'false').default('true'), | ||
|
|
||
| // CORS / Frontend — required in production; default to localhost in dev/test | ||
| ALLOWED_ORIGIN: Joi.string() | ||
| .uri() | ||
| .when('NODE_ENV', { | ||
| is: 'production', | ||
| then: Joi.required(), | ||
| otherwise: Joi.string().uri().default('http://localhost:5173'), | ||
| }), | ||
| FRONTEND_URL: Joi.string() | ||
| .uri() | ||
| .when('NODE_ENV', { | ||
| is: 'production', | ||
| then: Joi.required(), | ||
| otherwise: Joi.string().uri().default('http://localhost:5173'), | ||
| }), | ||
|
|
||
| // UEX Sync (all optional — service degrades gracefully when disabled) | ||
| // Use Joi.boolean() so env strings like 'false' are coerced to actual | ||
| // booleans; configService.get<boolean>(...) in the scheduler relies on this. | ||
| UEX_SYNC_ENABLED: Joi.boolean().default(false), | ||
| UEX_CATEGORIES_SYNC_ENABLED: Joi.boolean().default(false), | ||
| UEX_ITEMS_SYNC_ENABLED: Joi.boolean().default(false), | ||
| UEX_LOCATIONS_SYNC_ENABLED: Joi.boolean().default(false), | ||
| UEX_API_BASE_URL: Joi.string().uri().default('https://uexcorp.space/api/2.0'), | ||
| UEX_TIMEOUT_MS: Joi.number().default(60000), | ||
| UEX_BATCH_SIZE: Joi.number().default(100), | ||
| UEX_CONCURRENT_CATEGORIES: Joi.number().default(3), | ||
| UEX_RETRY_ATTEMPTS: Joi.number().default(3), | ||
| UEX_BACKOFF_BASE_MS: Joi.number().default(1000), | ||
| UEX_RATE_LIMIT_PAUSE_MS: Joi.number().default(2000), | ||
| UEX_ENDPOINTS_PAUSE_MS: Joi.number().default(2000), | ||
| UEX_API_KEY: Joi.string().allow('').default(''), | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.