-
Notifications
You must be signed in to change notification settings - Fork 6
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
Various internal auth and client changes #14
Conversation
@@ -9,77 +12,33 @@ const DEFAULT_OPTS = { | |||
'Accept': 'application/vnd.api+json; version=1' | |||
}, | |||
host: 'https://panoptes.zooniverse.org', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want to change this to zooniverse.org?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, will do
How does it work serverside. I think the json-api-client uses XMLHttpRequest which doesn't exist in node as far as I know? We could use something like superagent? |
It doesn't, and yeah, @brian-c mentioned using superagent in the client at one point as well. I've been polyfilling it with |
it uses https://github.com/chrissnyder/node-xmlhttprequest-cookie stubbed at https://github.com/zooniverse/panoptes-javascript-client/blob/refactor/src/client.js#L1-L4 to make XMLHttpRequest work in Node. Basically wraps http.request to give it the same API as xmlhttprequest. Better solution might be to use superagent within json-api-client rather than relying on this polyfill, but I took these changes independent of any changes to json-api-client. |
I can't build this. There's no |
Ah @chrissnyder you're only installing the XHR polyfill as a devDependency, so it won't be around if you include in a different project. |
Can now |
@brian-c Been meaning to talk with you about this, but keep getting pulled away on other things. Would still like your thoughts on the direction this is going and maybe it'd be best to put them here so others can chime in as well. |
Yeah, my only strong suggestions are to use superagent (like you're already discussing) and start using this in the PFE ASAP. When v2 of the API is ready we should drop JSON-API-Client for a generic adapter we don't have to maintain. That's going to be a nightmare amount of work, so something to start thinking about. Nice work! |
I just put in a pull request to add support for using superagent to the json-api-client lib: https://github.com/zooniverse/json-api-client/pulls |
Updated the PR to use Ed's superagent version of JAC. Also did some serious housecleaning of the gulp tasks and dependencies. |
Errors down the chain were causing change events to be fired erroneously.
@edpaget With https://github.com/zooniverse/json-api-client being merged in, I think this PR is also good to go. |
Is this ready to go? |
Will double check this afternoon and report back. |
Replaced by #20. |
@rogerhutchings and @edpaget would like different pairs of eyes on this to see if I'm moving in the right direction. Not ready to merge yet.
Now that a number of different custom projects are using the client, here are a number of refactorings that I believe supports custom development a bit better. In no particular order:
PanoptesClient
now extendsJSONAPIClient
. So no moreclient.api
to actually access the client.checkCurrent()
user promise and falls back to a simple evented system.client.auth
is an instance of EventEmitter. To catch auth changes, just listen forchange
onclient.auth