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

Commit

Permalink
refactor(config): use boolean schemas (#477)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Jan 17, 2022
1 parent f3fd622 commit 8a48911
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ async function getConfig() {
// CORS
.prop("CORS_ORIGIN", S.anyOf([S.string(), S.null()]))
.prop("CORS_ALLOWED_HEADERS", S.anyOf([S.string(), S.null()]))
.prop(
"CORS_ALLOW_CREDENTIALS",
S.anyOf([S.string().enum(["true"]), S.null()])
)
.prop("CORS_ALLOW_CREDENTIALS", S.anyOf([S.boolean(), S.null()]))
.prop("CORS_EXPOSED_HEADERS", S.anyOf([S.string(), S.null()]))
.prop("CORS_MAX_AGE", S.anyOf([S.number(), S.null()]))

Expand All @@ -80,10 +77,7 @@ async function getConfig() {
.prop("HTTPS_PFX_FILE_PATH", S.anyOf([S.string(), S.null()]))
.prop("HTTPS_SSL_CERT_PATH", S.anyOf([S.string(), S.null()]))
.prop("HTTPS_SSL_KEY_PATH", S.anyOf([S.string(), S.null()]))
.prop(
"HTTPS_HTTP2_ENABLED",
S.anyOf([S.string().enum(["true"]), S.null()])
)
.prop("HTTPS_HTTP2_ENABLED", S.anyOf([S.boolean(), S.null()]))

// Logger
.prop(
Expand Down Expand Up @@ -323,7 +317,7 @@ async function getConfig() {
};
}

if (String(env.CORS_ALLOW_CREDENTIALS) === "true") {
if (env.CORS_ALLOW_CREDENTIALS === true) {
config.cors.credentials = true;
}
if (env.CORS_ALLOWED_HEADERS) {
Expand Down Expand Up @@ -372,10 +366,7 @@ async function getConfig() {
}
}

if (
config.fastifyInit.https &&
String(env.HTTPS_HTTP2_ENABLED).toLowerCase().trim() === "true"
) {
if (config.fastifyInit.https && env.HTTPS_HTTP2_ENABLED === true) {
config.fastifyInit.https.allowHTTP1 = true;
config.fastifyInit.http2 = true;
}
Expand Down

0 comments on commit 8a48911

Please sign in to comment.