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

fix: don't modify the passed options object #559

Merged
merged 1 commit into from
Aug 30, 2016

Conversation

rmehner
Copy link
Contributor

@rmehner rmehner commented Aug 30, 2016

So in this project we're registering multiple servers as to Hapi, kinda like this:

var options = {
  db: {
    url: process.env.COUCH_URL
  }
}

server.register([
  { register: hoodie, options: options },
  { register: otherEndpoint, options: options }
], function (error) {})

the problem is, due to hoodie server's behaviour here, otherEndpoint never sees what's in options.db and will always have an empty object.

This PR fixes this behaviour by cloning the options object before doing anything on it.

@gr2m
Copy link
Member

gr2m commented Aug 30, 2016

LGTM, thanks Robin!
ping @hoodiehq/maintainers

@@ -10,10 +10,12 @@ var corsHeaders = require('hapi-cors-headers')
var hoodieServer = require('@hoodie/server').register
var log = require('npmlog')
var PouchDB = require('pouchdb-core')
var cloneDeep = require('lodash').cloneDeep
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn’t we decide on full loadash on the server instead of single functions?

No blocker tho

Copy link
Contributor Author

@rmehner rmehner Aug 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn’t we decide on full loadash on the server instead of single functions?

I've adapted from here:

var pick = require('lodash').pick

But yeah, found out about the CODING_STYLE.md now, will create another PR that fixes this inside of server/index.js.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the full lodash. the alternative would have been be require('lodash/cloneDeep')

@janl
Copy link
Member

janl commented Aug 30, 2016

LGTM

@gr2m gr2m merged commit 7a98915 into hoodiehq:master Aug 30, 2016
@gr2m gr2m removed the in progress label Aug 30, 2016
@rmehner rmehner deleted the fix/dont-touch-da-config branch August 30, 2016 17:30
rmehner added a commit to hoodiehq/ember-hoodie that referenced this pull request Aug 31, 2016
gr2m pushed a commit to hoodiehq/ember-hoodie that referenced this pull request Aug 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants