You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
672 B
24 lines
672 B
const { SystemSettings } = require("../../models/systemSettings");
|
|
|
|
// Explicitly check that a specific feature flag is enabled.
|
|
// This should match the key in the SystemSetting label.
|
|
function featureFlagEnabled(featureFlagKey = null) {
|
|
return async (_, response, next) => {
|
|
if (!featureFlagKey) return response.sendStatus(401).end();
|
|
|
|
const flagValue = (
|
|
await SystemSettings.get({ label: String(featureFlagKey) })
|
|
)?.value;
|
|
if (!flagValue) return response.sendStatus(401).end();
|
|
|
|
if (flagValue === "enabled") {
|
|
next();
|
|
return;
|
|
}
|
|
|
|
return response.sendStatus(401).end();
|
|
};
|
|
}
|
|
module.exports = {
|
|
featureFlagEnabled,
|
|
};
|