mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-07 12:07:07 +03:00
Migrate breaking config changes
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { SBSConfig } from "./types/config.model";
|
import { SBSConfig } from "./types/config.model";
|
||||||
import packageJson from "../package.json";
|
import packageJson from "../package.json";
|
||||||
|
import { RedisSearchLanguages } from "@node-redis/search/dist/commands";
|
||||||
|
|
||||||
const isTestMode = process.env.npm_lifecycle_script === packageJson.scripts.test;
|
const isTestMode = process.env.npm_lifecycle_script === packageJson.scripts.test;
|
||||||
const configFile = process.env.TEST_POSTGRES ? "ci.json"
|
const configFile = process.env.TEST_POSTGRES ? "ci.json"
|
||||||
@@ -8,6 +9,7 @@ const configFile = process.env.TEST_POSTGRES ? "ci.json"
|
|||||||
: "config.json";
|
: "config.json";
|
||||||
export const config: SBSConfig = JSON.parse(fs.readFileSync(configFile).toString("utf8"));
|
export const config: SBSConfig = JSON.parse(fs.readFileSync(configFile).toString("utf8"));
|
||||||
|
|
||||||
|
migrate(config);
|
||||||
addDefaults(config, {
|
addDefaults(config, {
|
||||||
port: 80,
|
port: 80,
|
||||||
behindProxy: "X-Forwarded-For",
|
behindProxy: "X-Forwarded-For",
|
||||||
@@ -109,3 +111,20 @@ function addDefaults(config: SBSConfig, defaults: SBSConfig) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function migrate(config: SBSConfig) {
|
||||||
|
// Redis change
|
||||||
|
if (config.redis) {
|
||||||
|
const redisConfig = config.redis as any;
|
||||||
|
if (redisConfig["host"] || redisConfig["port"]) {
|
||||||
|
config.redis.socket = {
|
||||||
|
host: redisConfig["host"],
|
||||||
|
port: redisConfig["port"]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (redisConfig["enable_offline_queue"] !== undefined) {
|
||||||
|
config.disableOfflineQueue = !redisConfig["enable_offline_queue"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user