Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow whole hoodie client config #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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.

Expand Down
5 changes: 1 addition & 4 deletions addon/services/hoodie.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down