mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-12 06:27:10 +03:00
migrate to typescript
This commit is contained in:
committed by
Dainius Dauksevicius
parent
c462323dd5
commit
08d27265fc
58
src/config.ts
Normal file
58
src/config.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import fs from 'fs';
|
||||
import {SBSConfig} from "./types/config.model";
|
||||
|
||||
const isTestMode = process.env.npm_lifecycle_script === 'ts-node test.ts';
|
||||
const configFile = isTestMode ? 'test.json' : 'config.json';
|
||||
export const config: SBSConfig = JSON.parse(fs.readFileSync(configFile).toString('utf8'));
|
||||
|
||||
addDefaults(config, {
|
||||
port: 80,
|
||||
behindProxy: "X-Forwarded-For",
|
||||
db: "./databases/sponsorTimes.db",
|
||||
privateDB: "./databases/private.db",
|
||||
createDatabaseIfNotExist: true,
|
||||
schemaFolder: "./databases",
|
||||
dbSchema: "./databases/_sponsorTimes.db.sql",
|
||||
privateDBSchema: "./databases/_private.db.sql",
|
||||
readOnly: false,
|
||||
webhooks: [],
|
||||
categoryList: ["sponsor", "intro", "outro", "interaction", "selfpromo", "music_offtopic"],
|
||||
maxNumberOfActiveWarnings: 3,
|
||||
hoursAfterWarningExpires: 24,
|
||||
adminUserID: "",
|
||||
discordCompletelyIncorrectReportWebhookURL: "",
|
||||
discordFirstTimeSubmissionsWebhookURL: "",
|
||||
discordNeuralBlockRejectWebhookURL: "",
|
||||
discordReportChannelWebhookURL: "",
|
||||
getTopUsersCacheTimeMinutes: 0,
|
||||
globalSalt: null,
|
||||
mode: "",
|
||||
neuralBlockURL: null,
|
||||
proxySubmission: null,
|
||||
rateLimit: {
|
||||
vote: {
|
||||
windowMs: 900000,
|
||||
max: 20,
|
||||
message: "Too many votes, please try again later",
|
||||
statusCode: 429,
|
||||
},
|
||||
view: {
|
||||
windowMs: 900000,
|
||||
max: 20,
|
||||
statusCode: 200,
|
||||
message: "", // TODO TYPESCRIPT whats the msg?
|
||||
},
|
||||
},
|
||||
userCounterURL: null,
|
||||
youtubeAPIKey: null,
|
||||
});
|
||||
|
||||
// Add defaults
|
||||
function addDefaults(config: SBSConfig, defaults: SBSConfig) {
|
||||
for (const key in defaults) {
|
||||
if (!config.hasOwnProperty(key)) {
|
||||
// @ts-ignore
|
||||
config[key] = defaults[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user