mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-10 17:00:11 +01:00
Simplify ENV management
auto write ENV on changes Dont double-track envs that are already tracked
This commit is contained in:
parent
524edd6e69
commit
9411791fe5
@ -145,7 +145,6 @@ function apiSystemEndpoints(app) {
|
||||
try {
|
||||
const body = reqBody(request);
|
||||
const { newValues, error } = await updateENV(body);
|
||||
if (process.env.NODE_ENV === "production") await dumpENV();
|
||||
response.status(200).json({ newValues, error });
|
||||
} catch (e) {
|
||||
console.log(e.message, e);
|
||||
|
@ -416,7 +416,6 @@ function systemEndpoints(app) {
|
||||
false,
|
||||
response?.locals?.user?.id
|
||||
);
|
||||
if (process.env.NODE_ENV === "production") await dumpENV();
|
||||
response.status(200).json({ newValues, error });
|
||||
} catch (e) {
|
||||
console.log(e.message, e);
|
||||
@ -451,8 +450,6 @@ function systemEndpoints(app) {
|
||||
true
|
||||
)?.error;
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV === "production") await dumpENV();
|
||||
response.status(200).json({ success: !error, error });
|
||||
} catch (e) {
|
||||
console.log(e.message, e);
|
||||
@ -493,7 +490,6 @@ function systemEndpoints(app) {
|
||||
},
|
||||
true
|
||||
);
|
||||
if (process.env.NODE_ENV === "production") await dumpENV();
|
||||
await Telemetry.sendTelemetry("enabled_multi_user_mode", {
|
||||
multiUserMode: true,
|
||||
});
|
||||
|
@ -719,6 +719,7 @@ async function updateENV(newENVs = {}, force = false, userId = null) {
|
||||
}
|
||||
|
||||
await logChangesToEventLog(newValues, userId);
|
||||
if (process.env.NODE_ENV === "production") await dumpENV();
|
||||
return { newValues, error: error?.length > 0 ? error : false };
|
||||
}
|
||||
|
||||
@ -751,6 +752,8 @@ async function dumpENV() {
|
||||
const frozenEnvs = {};
|
||||
const protectedKeys = [
|
||||
...Object.values(KEY_MAPPING).map((values) => values.envKey),
|
||||
// Manually Add Keys here which are not already defined in KEY_MAPPING
|
||||
// and are either managed or manually set ENV key:values.
|
||||
"STORAGE_DIR",
|
||||
"SERVER_PORT",
|
||||
// Password Schema Keys if present.
|
||||
@ -765,16 +768,6 @@ async function dumpENV() {
|
||||
"ENABLE_HTTPS",
|
||||
"HTTPS_CERT_PATH",
|
||||
"HTTPS_KEY_PATH",
|
||||
// DISABLED TELEMETRY
|
||||
"DISABLE_TELEMETRY",
|
||||
|
||||
// Agent Integrations
|
||||
// Search engine integrations
|
||||
"AGENT_GSE_CTX",
|
||||
"AGENT_GSE_KEY",
|
||||
"AGENT_SERPER_DEV_KEY",
|
||||
"AGENT_BING_SEARCH_API_KEY",
|
||||
"AGENT_SERPLY_API_KEY",
|
||||
];
|
||||
|
||||
// Simple sanitization of each value to prevent ENV injection via newline or quote escaping.
|
||||
|
Loading…
Reference in New Issue
Block a user