Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
PouchDB: function (dbName) {
// Folder to store tokens for this trustchain
const folder = `./data/${tankerConfig.trustchainId.replace(/[\/\\]/g, '_')}`;
// Ensure folder exists
if (!fs.existsSync(folder)) {
fs.mkdirSync(folder);
}
// Apply defaults
const PouchDB = PouchDBCore.defaults({ adapter: 'leveldb' });
// PouchDB will now persist data in the proper folder
return new PouchDB(`${folder}/${dbName}`);
}
}
options.dbUrl = createAuthDbUrl(log, options.dbUrlUsername, options.dbUrlPassword, options.dbUrl)
if (options.dbUrl) {
PouchDB.plugin(require('pouchdb-adapter-http'))
dbOptions.prefix = options.dbUrl
log.info('config', 'Storing all data in ' + options.dbUrl)
} else if (options.inMemory) {
PouchDB.plugin(require('pouchdb-adapter-memory'))
config.inMemory = true
log.info('config', 'Storing all data in memory only')
} else {
PouchDB.plugin(require(options.dbAdapter))
dbOptions.prefix = path.join(config.paths.data, 'data') + path.sep
log.info('config', 'Storing all data in ' + dbOptions.prefix + ' using ' + options.dbAdapter)
}
config.PouchDB = PouchDB.defaults(dbOptions)
return config
}