Skip to content

Commit

Permalink
Update to support Parse's new REST/CORS feature
Browse files Browse the repository at this point in the history
  • Loading branch information
srhyne committed Jan 27, 2012
1 parent 58d0762 commit 88ef3bf
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
19 changes: 13 additions & 6 deletions README.md
Expand Up @@ -5,13 +5,21 @@ It's a super light-weight AJAX wrapper for Parse.com's wonderful database servic
# Why did you build it?

I wanted a stupid-easy data store that I could use strictly from the client. No server needed!
One can simply write a thick front end application or app prototype and serve it from the file protocol
or through a Chrome extension.
Write a thick front end application or app prototype.

# Prototyping love.
# New!

__Serve your app from http, cross domain calls FTW!__
Parse launched support for __cross-origin__ resource sharing using CORS.
This means you no longer have to generate a base64 encoded Basic Auth key using the provided parse.sh
You can now just pass your application id and rest key right to `$.parse.init` and

Of course having your Parse.com authentication key sitting in your JS code is sort of a no-no.
However, for writing applications where you are focusing your effort first on the front end this is a great tool.
$.parse.init({
app_id : undefined, // <-- enter your Application Id here
rest_key : undefined // <--enter your REST API Key here
});

# Prototyping love.

* No Schema! Just fire a $.parse.post & forget it. If the collection hasn't been created already it will be
instantiated.
Expand All @@ -21,4 +29,3 @@ instantiated.
# More to come....

* Backbone / Spine sync extension
* Working on one for MongoHQ
5 changes: 2 additions & 3 deletions demo/demo.js
Expand Up @@ -6,9 +6,8 @@


$.parse.init({
//Enter a base64 Basic Auth string here..
// (Easiest way to get this is by running parse.sh and grabbing the auth output)
auth : undefined // <--- your basic auth key goes here!
app_id : undefined, // <-- enter your Application Id here
rest_key : undefined // <--enter your REST API Key here
});

function init(){
Expand Down
17 changes: 8 additions & 9 deletions jquery.parse.js
Expand Up @@ -18,11 +18,14 @@
function _creds(){
var error;

if(_opts.auth){
if(_opts.app_id && _opts.rest_key){
return true;
}

error = "Missing auth key. You should pass your basic Auth key to $."+ns+".init";
error = "Missing app_id, or rest_key authentication parameters.\n"+
"Pass these credentials to $."+ns+".init\n"+
"app_id = Application Id\n"+
"rest_key = REST API Key";
alert(error);
$.error(error);

Expand Down Expand Up @@ -52,14 +55,10 @@
type : method,

//Credentials
// -Note last I checked Stripe doesn't recognize Basic Auth sent through the URL scheme
username : _opts.app_id,
password : _opts.master_key,

//Have to manually set a basic auth header. See above.
//Use Parse.sh result to C&P your basic auth and pass in $.parse.init
//NEW! Parse.com now supports CORS...https://parse.com/docs/rest
headers : {
Authorization: "Basic " + _opts.auth
"X-Parse-Application-Id" : _opts.app_id,
"X-Parse-REST-API-Key" : _opts.rest_key
},
error : _error
};
Expand Down
1 change: 1 addition & 0 deletions parse.sh
Expand Up @@ -2,6 +2,7 @@

# Run this to get your base64 encoded Basic Auth header.
# Get your credentials at https://www.parse.com/apps/{your app}
# NEW! You don't need to use Basic auth now! Parse.com now supports CORS...https://parse.com/docs/rest

export APPLICATION_ID=""
export MASTER_KEY=""
Expand Down

0 comments on commit 88ef3bf

Please sign in to comment.