Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
require('dotenv').config()
const PouchDB = require('pouchdb-core')
PouchDB.plugin(require('pouchdb-adapter-mysql'))
PouchDB.plugin(require('pouchdb-find'))
const db = new PouchDB('data', { adapter: 'mysql' })
// sort the docs by the type property
db
.createIndex({ index: { fields: ['type'] } })
.then(() => {
console.log('Created an index on the type field.')
})
.catch(err => console.log(err))
// sort the docs by the name property
db
.createIndex({ index: { fields: ['name'] } })
.then(() => {
const fs = require('fs');
const PouchDBCore = require('pouchdb-core');
const PouchDBAdapterLevel = require('pouchdb-adapter-leveldb');
const PouchDBFind = require('pouchdb-find');
const tankerConfig = require('./config');
PouchDBCore.plugin(PouchDBAdapterLevel);
PouchDBCore.plugin(PouchDBFind);
// Custom setup to persist data with PouchDB in Node.js (not needed when
// using the tanker SDK in a browser application).
module.exports = {
config: {
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' });
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
import FauxtonAPI from "../../../core/api";
import {post} from "../../../core/ajax";
import ActionTypes from "./actiontypes";
import getTree from "visualize-rev-tree/lib/getTree";
import PouchDB from "pouchdb-core";
import PouchHttpAdapter from 'pouchdb-adapter-http';
PouchDB.plugin(PouchHttpAdapter);
let db;
export const initDiffEditor = (dbName, docId) => dispatch => {
// We have to use API url here because PouchDB doesn't take relative urls.
const url = FauxtonAPI.urls('databaseBaseURL', 'apiurl', dbName);
db = PouchDB(url);
Promise.all([db.get(docId), getTree(db, docId)])
.then(([doc, tree]) => {
const conflictingRevs = getConflictingRevs(tree.paths, tree.winner, Object.keys(tree.deleted));
const initialRev = conflictingRevs[0];
if (!initialRev) {
return dispatch(treeLoaded(tree, doc, conflictingRevs, null, dbName));
}
// custom version of pouchdb cutting out stuff we don't need
import PouchDB from 'pouchdb-core';
import idb from 'pouchdb-adapter-idb';
import websql from 'pouchdb-adapter-websql';
import http from 'pouchdb-adapter-http';
import upsert from 'pouchdb-upsert';
import load from 'pouchdb-load';
export default PouchDB
.plugin(idb)
.plugin(websql)
.plugin(http)
.plugin(upsert)
.plugin(load);
import PouchDB from 'pouchdb-core'
// All Environments
let configuredPouch = PouchDB
.plugin(require('pouchdb-find').default)
if(process.env["NODE_ENV"] === 'test' && typeof window === 'undefined') {
// Node tests, include extra libs for speed
configuredPouch
.plugin(require('pouchdb-adapter-memory').default)
configuredPouch = configuredPouch.defaults({ adapter: 'memory' })
} else {
// Any environment with a window
configuredPouch
.plugin(require('pouchdb-adapter-idb').default)
.plugin(require('pouchdb-adapter-websql').default)
}
export default configuredPouch
export const initDiffEditor = (dbName, docId) => dispatch => {
// We have to use API url here because PouchDB doesn't take relative urls.
const url = FauxtonAPI.urls('databaseBaseURL', 'apiurl', dbName);
db = PouchDB(url);
Promise.all([db.get(docId), getTree(db, docId)])
.then(([doc, tree]) => {
const conflictingRevs = getConflictingRevs(tree.paths, tree.winner, Object.keys(tree.deleted));
const initialRev = conflictingRevs[0];
if (!initialRev) {
return dispatch(treeLoaded(tree, doc, conflictingRevs, null, dbName));
}
db.get(doc._id, {rev: initialRev})
.then((conflictDoc) => {
dispatch(treeLoaded(tree, doc, conflictingRevs, conflictDoc, dbName));
});
});
};
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}`);
}
}
const url = require('url')
const PouchDB = require('pouchdb-core')
.plugin(require('pouchdb-adapter-http'))
const SpeechToTextV1 = require('watson-developer-cloud/speech-to-text/v1')
const NaturalLanguageUnderstandingV1 = require('watson-developer-cloud/natural-language-understanding/v1.js')
const stream = require('stream')
const ffmpeg = require('fluent-ffmpeg')
const [couchUrl, dbName] = process.argv.slice(2)
const {
SPEECH_TO_TEXT_USERNAME,
SPEECH_TO_TEXT_PASSWORD,
NATURAL_LANGUAGE_UNDERSTANDING_USERNAME,
NATURAL_LANGUAGE_UNDERSTANDING_PASSWORD
} = process.env
if (!couchUrl) {
console.log('Usage: node bin/couch-doctor.js https://user:password@couchhost.com [dbName]')
let PouchDB;
if(typeof process !== 'undefined' && process.versions && process.versions.node) {
PouchDB = require('pouchdb-core')
.plugin(require('pouchdb-adapter-http'))
.plugin(require('pouchdb-replication'))
.plugin(require('pouchdb-mapreduce'))
.plugin(require('pouchdb-find'))
.plugin(require('pouchdb-adapter-memory'));
}
else {
if(window.PouchDB) {
PouchDB = window.PouchDB;
}
else {
PouchDB = window.PouchDB = require('pouchdb-core').default
.plugin(require('pouchdb-adapter-http').default)
.plugin(require('pouchdb-replication').default)
.plugin(require('pouchdb-mapreduce').default)
.plugin(require('pouchdb-find').default)
.plugin(require('pouchdb-adapter-idb').default);
}
}
var PouchDB$1 = PouchDB;
function adapter({AbstracrAdapter}) {
const fieldsToDelete = '_id,search,timestamp'.split(',');
return class AdapterPouch extends AbstracrAdapter {
constructor($p) {
super($p);
this.props = {
_data_loaded: false,
import PouchDB from 'pouchdb-core';
import IDBPouch from 'pouchdb-adapter-idb';
import HttpPouch from 'pouchdb-adapter-http';
import mapreduce from 'pouchdb-mapreduce';
import replication from 'pouchdb-replication';
PouchDB.plugin(IDBPouch)
.plugin(HttpPouch)
.plugin(mapreduce)
.plugin(replication);
export default PouchDB;