This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from feedhenry/default-handler
fh-sync default handler support
- Loading branch information
Showing
20 changed files
with
117 additions
and
7,002 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
test/browser/browserified_tests.js | ||
test/browser/feedhenry-latest-require.js | ||
test | ||
example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,10 @@ | ||
language: node_js | ||
sudo: false | ||
node_js: | ||
- '0.10' | ||
- "4.4.3" | ||
before_install: | ||
- npm install -g [email protected] | ||
- npm install -g grunt-cli | ||
install: npm install | ||
script: | ||
- grunt | ||
deploy: | ||
provider: releases | ||
api_key: | ||
secure: AXggnsDClUChq5mRqudXKiDS8g5Mbjv0J/vEOj5vdVYxJgII2+pHcJpFAEtU0hKjiMgWPTtLDDUmjS61iGI9WcxrNKKwGohhORXQk/CPxRUA69AaXOPOUP1p0Sdcyy2NM1NJ1N75mhDkYfrnhlVuafSPKb8DaSjsyjD0JdIoXe4= | ||
file: | ||
- $TRAVIS_BUILD_DIR/dist/feedhenry-js.zip | ||
- $TRAVIS_BUILD_DIR/dist/feedhenry-titanium.zip | ||
- $TRAVIS_BUILD_DIR/dist/fh-starter-project-latest.zip | ||
skip_cleanup: true | ||
on: | ||
repo: feedhenry/fh-js-sdk | ||
tags: true | ||
all_branches: true | ||
- grunt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
{ | ||
"name": "fh-js-sdk", | ||
"version": "2.17.0", | ||
"homepage": "https://github.com/feedhenry/fh-js-sdk", | ||
"name": "fh-sync-js", | ||
"version": "1.0.0", | ||
"homepage": "https://github.com/feedhenry/fh-sync-js", | ||
"authors": [ | ||
"[email protected]" | ||
], | ||
"description": "FeedHenry JS SDK", | ||
"main": "dist/feedhenry.js", | ||
"description": "Feedhenry sync", | ||
"main": "dist/fh-sync.js", | ||
"keywords": [ | ||
"feedhenry", | ||
"mobile", | ||
"html5", | ||
"mbaas", | ||
"sdk" | ||
"fhsync" | ||
], | ||
"license": "Copyright (c) 2014 FeedHenry Ltd, All Rights Reserved.", | ||
"license": "Apache 2.0 License", | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
This dir is for third party libraries. To add a library to the final dist/feedhenry-latest.js you will need to add it to the grunt.js file | ||
This dir is for third party libraries. To add a library to the final dist you will need to add it to the grunt.js file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
var cloudURL; | ||
var cloudPath; | ||
|
||
/** | ||
* Default sync cloud handler responsible for making all sync requests to | ||
* server. | ||
*/ | ||
var handler = function (params, success, failure) { | ||
if (!cloudPath) { | ||
// Default server sync api route | ||
cloudPath = '/sync/'; | ||
} | ||
var url = cloudURL + cloudPath + params.dataset_id; | ||
var json = JSON.stringify(params.req); | ||
|
||
var xhr = new XMLHttpRequest(); | ||
xhr.open("POST", url, true); | ||
xhr.setRequestHeader('Content-type', 'application/json; charset=utf-8'); | ||
xhr.onreadystatechange = function () { | ||
if (xhr.readyState === XMLHttpRequest.DONE) { | ||
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) { | ||
var responseJson; | ||
try { | ||
if (xhr.responseText) { | ||
responseJson = JSON.parse(xhr.responseText); | ||
} | ||
} catch (e) { | ||
return failure(e); | ||
} | ||
success(responseJson); | ||
} else { | ||
failure(xhr.responseText); | ||
} | ||
} | ||
}; | ||
xhr.send(json); | ||
}; | ||
|
||
/** | ||
* Default sync cloud handler init method | ||
* | ||
* @param url - for example http://example.com:7000 | ||
* @param path - api path (will default to '/sync') | ||
*/ | ||
var init = function (url, path) { | ||
cloudURL = url; | ||
cloudPath = path; | ||
}; | ||
|
||
module.exports = { | ||
handler: handler, | ||
init: init | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.