Skip to content

Commit

Permalink
Increase db connection timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrsn committed Aug 22, 2017
1 parent f9328a7 commit ff4f788
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "medic-configurer-beta",
"version": "1.4.0",
"version": "1.4.1",
"description": "Configure Medic Mobile deployments",
"main": "index.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/fn/backup-all-forms.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const log = require('../lib/log');
const fs = require('../lib/sync-fs');
const skipFn = require('../lib/skip-fn');
const PouchDB = require('pouchdb');
const pouch = require('../lib/db');

const backupFileFor = require('../lib/backup-file-for');

module.exports = (projectDir, couchUrl) => {
if(!couchUrl) return skipFn('no couch URL set');

const db = new PouchDB(couchUrl);
const db = new pouch(couchUrl);
const parentBackupDir = backupFileFor(projectDir, 'forms');

log('Backing up forms to:', parentBackupDir);
Expand Down
4 changes: 2 additions & 2 deletions src/fn/delete-all-forms.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const skipFn = require('../lib/skip-fn');
const PouchDB = require('pouchdb');
const pouch = require('../lib/db');

module.exports = (projectDir, couchUrl) => {
if(!couchUrl) return skipFn('no couch URL set');

const db = new PouchDB(couchUrl);
const db = new pouch(couchUrl);

return db.query('medic-client/forms', { include_docs:true })
.then(res => res.rows)
Expand Down
4 changes: 2 additions & 2 deletions src/fn/upload-custom-translations.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const fs = require('../lib/sync-fs');
const skipFn = require('../lib/skip-fn');
const warn = require('../lib/log').warn;
const PouchDB = require('pouchdb');
const pouch = require('../lib/db');

const FILE_MATCHER = /messages-.*\.properties/;

module.exports = (projectDir, couchUrl) => {
if(!couchUrl) return skipFn('no couch URL set');

const dir = `${projectDir}/translations`;
const db = new PouchDB(couchUrl);
const db = new pouch(couchUrl);

return Promise.resolve()
.then(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/fn/upload-resources.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = require('../lib/sync-fs');
const skipFn = require('../lib/skip-fn');
const warn = require('../lib/log').warn;
const PouchDB = require('pouchdb');
const pouch = require('../lib/db');

const attachmentsFromDir = require('../lib/attachments-from-dir');
const insertOrReplace = require('../lib/insert-or-replace');
Expand All @@ -16,7 +16,7 @@ module.exports = (projectDir, couchUrl) => {
return Promise.resolve();
}

const db = new PouchDB(couchUrl);
const db = new pouch(couchUrl);

return insertOrReplace(db, {
_id: 'resources',
Expand Down
3 changes: 3 additions & 0 deletions src/lib/db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const PouchDB = require('pouchdb');

module.exports = url => new PouchDB(url, { ajax: { timeout: 60000 } });
5 changes: 2 additions & 3 deletions src/lib/upload-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ const insertOrReplace = require('../lib/insert-or-replace');
const skipFn = require('../lib/skip-fn');
const trace = require('../lib/log').trace;
const warn = require('../lib/log').warn;
const PouchDB = require('pouchdb');

const pouch = require('../lib/db');

const SUPPORTED_PROPERTIES = ['context', 'icon', 'internalId', 'title'];


module.exports = (projectDir, couchUrl, subDirectory, options) => {
if(!couchUrl) return skipFn('no couch URL set');

const db = new PouchDB(couchUrl);
const db = new pouch(couchUrl);

if(!options) options = {};

Expand Down

0 comments on commit ff4f788

Please sign in to comment.