-
Notifications
You must be signed in to change notification settings - Fork 0
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
BC-8092 - implement config validation #21
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f7081a6
BC-8092 - implement config validation
SevenWaysDP 5fb4178
BC-8092 - fix mocks for Redis and @y/redis
SevenWaysDP 5f355b8
fix tests
SevenWaysDP 173fbd7
fixup! fix tests
SevenWaysDP fa3f52a
fixup! fix tests
SevenWaysDP d003566
BC-8092 - code review
SevenWaysDP 7df8094
BC-8092 - fix sonercloud issues
SevenWaysDP f400d33
Refactor configuration module and fix error handling in storage service
SevenWaysDP aa65fc6
Refactor RedisConfig class and enable Redis cluster support
SevenWaysDP ea88874
Refactor error handling in StorageService and remove unnecessary logging
SevenWaysDP 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
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,13 +1,9 @@ | ||
REDIS=redis://172.18.0.5:6379 | ||
REDIS_PREFIX=y | ||
REDIS=redis://localhost:6379 | ||
API_HOST=http://localhost:3030 | ||
ADMIN_API__ALLOWED_API_KEYS=randomString | ||
|
||
S3_ENDPOINT=localhost | ||
S3_BUCKET=ydocs | ||
S3_PORT=9000 | ||
S3_SSL=false | ||
S3_ACCESS_KEY=miniouser | ||
S3_SECRET_KEY=miniouser | ||
|
||
WS_PORT="3345" |
This file contains 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,9 @@ | ||
REDIS=redis://localhost:6379 | ||
API_HOST=http://localhost:3030 | ||
ADMIN_API__ALLOWED_API_KEYS=randomString | ||
|
||
S3_ENDPOINT=localhost | ||
S3_PORT=9000 | ||
S3_SSL=false | ||
S3_ACCESS_KEY=miniouser | ||
S3_SECRET_KEY=miniouser |
This file contains 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.
This file contains 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 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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 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 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,8 @@ | ||
import { Transform } from 'class-transformer'; | ||
import { IsArray } from 'class-validator'; | ||
|
||
export class XApiKeyConfig { | ||
@Transform(({ value }) => value.split(',').map((part: string) => (part.split(':').pop() ?? '').trim())) | ||
@IsArray() | ||
public ADMIN_API__ALLOWED_API_KEYS!: string[]; | ||
} |
This file contains 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,6 @@ | ||
import { IsUrl } from 'class-validator'; | ||
|
||
export class AuthorizationConfig { | ||
@IsUrl({ require_tld: false }) | ||
public API_HOST!: string; | ||
} |
This file contains 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 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 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 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,40 @@ | ||
import { DynamicModule, Module } from '@nestjs/common'; | ||
import { ConfigModule, ConfigModuleOptions } from '@nestjs/config'; | ||
import { Configuration } from './configuration.service.js'; | ||
|
||
const getEnvConfig = (): ConfigModuleOptions => { | ||
const envConfig = { | ||
cache: true, | ||
envFilePath: '.env', | ||
ignoreEnvFile: false, | ||
}; | ||
|
||
if (process.env.NODE_ENV === 'test') { | ||
envConfig.envFilePath = '.env.test'; | ||
} | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
envConfig.ignoreEnvFile = true; | ||
} | ||
|
||
return envConfig; | ||
}; | ||
|
||
@Module({}) | ||
export class ConfigurationModule { | ||
public static register<T extends object>(Constructor: new () => T): DynamicModule { | ||
return { | ||
imports: [ConfigModule.forRoot(getEnvConfig())], | ||
providers: [ | ||
Configuration, | ||
{ | ||
provide: Constructor, | ||
useFactory: (config: Configuration): T => config.getAllValidConfigsByType(Constructor), | ||
inject: [Configuration], | ||
}, | ||
], | ||
CeEv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
exports: [Configuration, Constructor], | ||
module: ConfigurationModule, | ||
}; | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
configuration und config sind sich zu ähnlich um ausdrücken zu können was für was ist.