Skip to content

Commit

Permalink
api: Update ENV validation to allow empty values for some vars
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelPull authored Oct 24, 2024
1 parent 6f2e50d commit 5fcc8bc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ scripts/development/certs
scripts/operation/.env
.idea/
docs/developer/api-docs
scripts/development/.env.bak
scripts/operation/.env.bak
scripts/operation/cronjob.err
scripts/operation/cronjob.output
Expand Down
12 changes: 12 additions & 0 deletions api/src/envVarsSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ export const envVarsSchema = Joi.object({
.default(false)
.note("Enables logging in using the authorization token from authentication proxy"),
AUTHPROXY_JWS_SIGNATURE: Joi.string()
.allow("")
.empty("")
.when("AUTHPROXY_ENABLED", {
is: true,
then: Joi.required(),
Expand All @@ -169,12 +171,16 @@ export const envVarsSchema = Joi.object({
SQL_DEBUG: Joi.boolean().default(false),
API_DB_USER: Joi.string()
.default("postgres")
.allow("")
.empty("")
.when("REFRESH_TOKEN_STORAGE", {
is: "db",
then: Joi.required(),
})
.note("Database user for database connection, e.g. postgres"),
API_DB_PASSWORD: Joi.string()
.allow("")
.empty("")
.when("REFRESH_TOKEN_STORAGE", {
is: "db",
then: Joi.required(),
Expand All @@ -186,6 +192,8 @@ export const envVarsSchema = Joi.object({
is: "db",
then: Joi.required(),
})
.allow("")
.empty("")
.default("localhost")
.note("Database host"),
API_DB_NAME: Joi.string()
Expand All @@ -202,13 +210,17 @@ export const envVarsSchema = Joi.object({
is: "db",
then: Joi.required(),
})
.allow("")
.empty("")
.default(5432)
.note("Database port, e.g. 5432"),
API_DB_SSL: Joi.boolean()
.when("REFRESH_TOKEN_STORAGE", {
is: "db",
then: Joi.required(),
})
.allow("")
.empty("")
.default(false)
.note('Database SSL connection. Allowed values: "true" or "false".'),
API_DB_SCHEMA: Joi.string()
Expand Down
1 change: 1 addition & 0 deletions scripts/operation/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ REACT_APP_API_SERVICE_ADDITIONAL_NGINX_CONF=""
REACT_APP_EMAIL_SERVICE_ADDITIONAL_NGINX_CONF=""
REACT_APP_EXPORT_SERVICE_ADDITIONAL_NGINX_CONF=""
REACT_APP_STORAGE_SERVICE_ADDITIONAL_NGINX_CONF=""
AUTHPROXY_ENABLED=false

## excel-export
ACCESS_CONTROL_ALLOW_ORIGIN=*
Expand Down

0 comments on commit 5fcc8bc

Please sign in to comment.