mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-30 03:03:06 -05:00
fix(api): only treat undefined as unset (#58120)
This commit is contained in:
@@ -119,7 +119,7 @@ export const build = async (
|
||||
void fastify.register(mailer, { provider });
|
||||
|
||||
// Swagger plugin
|
||||
if (FCC_ENABLE_SWAGGER_UI || fastify.gb.isOn('swagger-ui')) {
|
||||
if (FCC_ENABLE_SWAGGER_UI ?? fastify.gb.isOn('swagger-ui')) {
|
||||
void fastify.register(fastifySwagger, {
|
||||
openapi: {
|
||||
openapi: '3.1.0',
|
||||
@@ -147,7 +147,7 @@ export const build = async (
|
||||
fastify.log.info(`Swagger UI available at ${API_LOCATION}/documentation`);
|
||||
}
|
||||
|
||||
if (FCC_ENABLE_SHADOW_CAPTURE || fastify.gb.isOn('shadow-capture')) {
|
||||
if (FCC_ENABLE_SHADOW_CAPTURE ?? fastify.gb.isOn('shadow-capture')) {
|
||||
void fastify.register(shadowCapture);
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ export const build = async (
|
||||
}
|
||||
});
|
||||
|
||||
if (FCC_ENABLE_EXAM_ENVIRONMENT || fastify.gb.isOn('exam-environment')) {
|
||||
if (FCC_ENABLE_EXAM_ENVIRONMENT ?? fastify.gb.isOn('exam-environment')) {
|
||||
void fastify.register(function (fastify, _opts, done) {
|
||||
fastify.addHook('onRequest', fastify.authorizeExamEnvironmentToken);
|
||||
|
||||
@@ -214,7 +214,7 @@ export const build = async (
|
||||
void fastify.register(examEnvironmentOpenRoutes);
|
||||
}
|
||||
|
||||
if (FCC_ENABLE_SENTRY_ROUTES || fastify.gb.isOn('sentry-routes')) {
|
||||
if (FCC_ENABLE_SENTRY_ROUTES ?? fastify.gb.isOn('sentry-routes')) {
|
||||
void fastify.register(publicRoutes.sentryRoutes);
|
||||
}
|
||||
|
||||
|
||||
@@ -159,17 +159,21 @@ export const PORT = process.env.PORT || '3000';
|
||||
// container.
|
||||
export const HOST = process.env.HOST || '0.0.0.0';
|
||||
export const API_LOCATION = process.env.API_LOCATION;
|
||||
export const FCC_ENABLE_SWAGGER_UI =
|
||||
process.env.FCC_ENABLE_SWAGGER_UI === 'true';
|
||||
export const FCC_ENABLE_SWAGGER_UI = undefinedOrBool(
|
||||
process.env.FCC_ENABLE_SWAGGER_UI
|
||||
);
|
||||
export const FCC_ENABLE_DEV_LOGIN_MODE =
|
||||
process.env.FCC_ENABLE_DEV_LOGIN_MODE === 'true';
|
||||
export const FCC_API_LOG_LEVEL = _FCC_API_LOG_LEVEL;
|
||||
export const FCC_ENABLE_SHADOW_CAPTURE =
|
||||
process.env.FCC_ENABLE_SHADOW_CAPTURE === 'true';
|
||||
export const FCC_ENABLE_EXAM_ENVIRONMENT =
|
||||
process.env.FCC_ENABLE_EXAM_ENVIRONMENT === 'true';
|
||||
export const FCC_ENABLE_SENTRY_ROUTES =
|
||||
process.env.FCC_ENABLE_SENTRY_ROUTES === 'true';
|
||||
export const FCC_ENABLE_SHADOW_CAPTURE = undefinedOrBool(
|
||||
process.env.FCC_ENABLE_SHADOW_CAPTURE
|
||||
);
|
||||
export const FCC_ENABLE_EXAM_ENVIRONMENT = undefinedOrBool(
|
||||
process.env.FCC_ENABLE_EXAM_ENVIRONMENT
|
||||
);
|
||||
export const FCC_ENABLE_SENTRY_ROUTES = undefinedOrBool(
|
||||
process.env.FCC_ENABLE_SENTRY_ROUTES
|
||||
);
|
||||
export const FREECODECAMP_NODE_ENV = _FREECODECAMP_NODE_ENV;
|
||||
export const SENTRY_DSN =
|
||||
process.env.SENTRY_DSN === 'dsn_from_sentry_dashboard'
|
||||
@@ -192,3 +196,11 @@ export const GROWTHBOOK_FASTIFY_API_HOST =
|
||||
process.env.GROWTHBOOK_FASTIFY_API_HOST;
|
||||
export const GROWTHBOOK_FASTIFY_CLIENT_KEY =
|
||||
process.env.GROWTHBOOK_FASTIFY_CLIENT_KEY;
|
||||
|
||||
function undefinedOrBool(val: string | undefined): undefined | boolean {
|
||||
if (!val) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return val === 'true';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user