UNPKG

taapi-cache

Version:

TAAPI.IO Cache Package. A convenient way to fetch candles, store them and reuse them.

80 lines (67 loc) 2.33 kB
const chalk = require("chalk"); let environment = false; try { environment = require("../../../../config"); } catch (error) { console.log(chalk.red("Error: config.js not present. Please copy and configure it: \n - cp node_modules/taapi-cache/config.js .")); process.exit(1); } ; const config = { validateEnvironment: async () => { // Dependencies const database = require("../utilities/Database"); // Load the admin database await database.getDatabase(); let configOk = true; // Database if (!environment.database) { console.log(chalk.red("Error: config.database is not set")); configOk = false; } if (!environment.database.name) { console.log(chalk.red("Error: config.database.name is not set")); configOk = false; } if (!environment.database.host) { console.log(chalk.red("Error: config.database.host is not set")); configOk = false; } if (!environment.database.port) { console.log(chalk.red("Error: config.database.port is not set")); configOk = false; } if (!environment.database.user) { console.log(chalk.yellow("Warning: config.database.user is not set")); } if (!environment.database.pass) { console.log(chalk.yellow("Warning: config.database.pass is not set")); } if (!environment.dataProviders) { console.log(chalk.yellow("Warning: config.dataProviders is not set")); } if (configOk) { console.log(chalk.green("Configuration environment OK!")); } else { console.log(chalk.red("Configuration environment NOT OK!")); } }, server: { host: environment.server.host, port: environment.server.port, debugMode: environment.server.debugMode || false }, auth: { secret: environment.auth.secret }, database: { name: environment.database.name, uri: () => { if (environment.database.user && environment.database.pass) { return `mongodb://${environment.database.user}:${environment.database.pass}@${environment.database.host}:${environment.database.port}/${environment.database.name}`; } else { return `mongodb://${environment.database.host}:${environment.database.port}/${environment.database.name}`; } } }, dataProviders: environment.dataProviders }; module.exports = config;