From 8dd726b7b0efcc19405b6c0f4f0a95e21930c967 Mon Sep 17 00:00:00 2001 From: Bruno Pedroso Date: Thu, 4 May 2017 15:09:28 -0300 Subject: [PATCH] feat: allow whole hoodie client config --- README.md | 17 +++++++++++++---- addon/services/hoodie.js | 5 +---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 3acac66..3a96fcf 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,8 @@ var PouchDB = require('pouchdb'); if (environment === 'development') { ENV.hoodie = { client: { - url: 'http://localhost:4200' + url: 'http://localhost:4200', + PouchDB: PouchDB }, server: { PouchDB: PouchDB, @@ -77,19 +78,26 @@ if (environment === 'development') { } ``` -The `ENV.hoodie.server` property is the exact hoodie-server config that will be passed as hapi's `register` [options](https://github.com/hoodiehq/hoodie-server#example). So you can pass whatever options you need here. For example, to make hoodie act as a proxy to a couchdb, you can use: +The `ENV.hoodie.server` property is the exact hoodie-server config that will be passed as hapi's `register` [options](https://github.com/hoodiehq/hoodie-server#example). + +The `ENV.hoodie.client` property, as well, is passed as-is to the [hoodie-client contstructor](https://github.com/hoodiehq/hoodie-client#constructor). + +So you can pass whatever options you need here. + +For example, to make hoodie-server act as a proxy to a couchdb, you can use: ```js ENV.hoodie = { client: { - url: 'http://localhost:4200' + url: 'http://localhost:4200', + PouchDB: PouchDB }, server: { PouchDB: PouchDB.defaults({ prefix: 'http://localhost:5984', auth: { username: 'admin', - password: 'admin' + password: 'secret' } }), port: 4201, @@ -98,6 +106,7 @@ The `ENV.hoodie.server` property is the exact hoodie-server config that will be }; ``` + Now, you can just use the store as you are used to! Whabam! Please help me fill out these docs a little better. diff --git a/addon/services/hoodie.js b/addon/services/hoodie.js index 90dc12e..064de2b 100644 --- a/addon/services/hoodie.js +++ b/addon/services/hoodie.js @@ -10,10 +10,7 @@ export default Service.extend({ init() { this._super(...arguments); const appConfig = Ember.getOwner(this).application.resolveRegistration('config:environment'); - const hoodie = new Hoodie({ - url : appConfig.hoodie.client.url, - PouchDB : PouchDB - }); + const hoodie = new Hoodie(appConfig.hoodie.client); set(this, 'hoodie', hoodie); // for debug only window.hoodie = hoodie;