Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public static getToolDependencies(
configFile: string, regFile: string = "./discord-registration.yaml", needsStore: boolean = true): {
store: DiscordStore|null,
appservice: Appservice,
config: DiscordBridgeConfig,
} {
const registration = yaml.safeLoad(fs.readFileSync(regFile, "utf8"));
const config: DiscordBridgeConfig = yaml.safeLoad(fs.readFileSync(configFile, "utf8")) as DiscordBridgeConfig;
config.applyEnvironmentOverrides(process.env);
if (registration === null) {
throw Error("Failed to parse registration file");
}
const appservice = new Appservice({
bindAddress: "notathing",
homeserverName: config.bridge.domain,
homeserverUrl: config.bridge.homeserverUrl,
port: 0,
registration,
});
const store = needsStore ? new DiscordStore(config.database ? config.database.filename : "discord.db") : null;
return {
appservice,
config,
store,
};
}
}