Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Commit

Permalink
fix(config): default throws exceptions when used in anyOf schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Aug 25, 2022
1 parent 3368aa0 commit 81dd1fd
Showing 1 changed file with 18 additions and 34 deletions.
52 changes: 18 additions & 34 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,31 +68,24 @@ async function getConfig() {
.prop(
"LOG_LEVEL",
S.anyOf([
S.string()
.enum([
"fatal",
"error",
"warn",
"info",
"debug",
"trace",
"silent",
])
.default("info"),
S.string().enum([
"fatal",
"error",
"warn",
"info",
"debug",
"trace",
"silent",
]),
S.null(),
])
)
.prop(
"LOG_ROTATION_DATE_FORMAT",
S.anyOf([S.string().default("YYYY-MM-DD"), S.null()])
)
.prop("LOG_ROTATION_DATE_FORMAT", S.anyOf([S.string(), S.null()]))
.prop("LOG_ROTATION_FILENAME", S.anyOf([S.string(), S.null()]))
.prop(
"LOG_ROTATION_FREQUENCY",
S.anyOf([
S.string()
.enum(["custom", "daily", "test"])
.default("daily"),
S.string().enum(["custom", "daily", "test"]),
S.null(),
])
)
Expand All @@ -102,45 +95,36 @@ async function getConfig() {
// Process Load Handling
.prop(
"PROC_LOAD_MAX_EVENT_LOOP_DELAY",
S.anyOf([S.number().default(0), S.null()])
S.anyOf([S.number(), S.null()])
)
.prop(
"PROC_LOAD_MAX_EVENT_LOOP_UTILIZATION",
S.anyOf([S.number().default(0), S.null()])
S.anyOf([S.number(), S.null()])
)
.prop(
"PROC_LOAD_MAX_HEAP_USED_BYTES",
S.anyOf([S.number().default(0), S.null()])
)
.prop(
"PROC_LOAD_MAX_RSS_BYTES",
S.anyOf([S.number().default(0), S.null()])
S.anyOf([S.number(), S.null()])
)
.prop("PROC_LOAD_MAX_RSS_BYTES", S.anyOf([S.number(), S.null()]))

// Rate Limiting
.prop("RATE_LIMIT_EXCLUDED_ARRAY", S.anyOf([S.string(), S.null()]))
.prop(
"RATE_LIMIT_MAX_CONNECTIONS_PER_MIN",
S.anyOf([S.number().default(1000), S.null()])
S.anyOf([S.number(), S.null()])
)

// Admin login
.prop("ADMIN_USERNAME", S.string())
.prop("ADMIN_PASSWORD", S.string().minLength(8))

// Bearer token auth
.prop(
"BEARER_TOKEN_AUTH_ENABLED",
S.anyOf([S.boolean().default(false), S.null()])
)
.prop("BEARER_TOKEN_AUTH_ENABLED", S.anyOf([S.boolean(), S.null()]))

// Database Connection
.prop(
"DB_CLIENT",
S.anyOf([
S.string().enum(["mssql", "postgresql"]).default("mssql"),
S.null(),
])
S.anyOf([S.string().enum(["mssql", "postgresql"]), S.null()])
)
.prop("DB_CONNECTION_STRING", S.string())
.required([
Expand Down

0 comments on commit 81dd1fd

Please sign in to comment.