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 17
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 #6 from feedhenry/remove-fh-mbaas-express
Proposed restructuring for removal of fh-mbaas-express issue #2
- Loading branch information
Showing
69 changed files
with
108 additions
and
3,299 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,58 +1,56 @@ | ||
# fh-sync cloud | ||
# fh-sync | ||
|
||
Node.js and express.js based mobile app data synchronization library. | ||
Node.js implementation of the FeedHenry Data Syncronisation Server. | ||
To be used in conjunction with the FeedHenry Data Syncronisation Client. | ||
|
||
*Note* WIP. This repo targets to decouple fh-sync from other API's in fh-mbaas-api package. | ||
For official and supported version of fh-sync please refer to fh-mbaas-api npm package. | ||
*Note* WIP. The goal of this repo is to decouple fh-sync from other API's in fh-mbaas-api package. | ||
For the currently maintained fh-sync implementation, please refer to https://github.com/feedhenry/fh-mbaas-api. | ||
|
||
## Usage | ||
fh-sync is included as standard with your cloud app code. | ||
|
||
``` | ||
npm install --save fh-sync-cloud | ||
npm install --save fh-sync | ||
``` | ||
|
||
This will install the latest version of fh-sync-cloud and save the installed version in your package.json | ||
This will install the latest version of fh-sync and save the installed version in your package.json | ||
|
||
## Documentation | ||
Documentation for the fh-sync-cloud API is maintained at the [FeedHenry API Docs.](http://docs.feedhenry.com/v3/api/cloud_api.html) | ||
To use sync in your application, require it and call `connect`. | ||
|
||
```js | ||
var sync = require('fh-sync'); | ||
|
||
## Tests | ||
In order to run the tests, please make sure you have [Docker](https://www.docker.com/) installed. | ||
|
||
Before running tests do: | ||
var mongodbConnectionString = 'mongodb://127.0.0.1:27017/sync'; | ||
var redisUrl = 'redis://127.0.0.1:6379'; | ||
|
||
``` | ||
npm install | ||
npm install -g grunt-cli | ||
sync.api.connect(mongodbConnectionString, {}, redisUrl, function(){}); | ||
``` | ||
|
||
Then to run the tests use ```npm test``` | ||
To configure a dataset for syncing, wait for the `sync:ready` event, then `init` the dataset. | ||
|
||
## Caveats | ||
```js | ||
sync.api.getEventEmitter().on('sync:ready', function() { | ||
console.log('sync ready'); | ||
|
||
### Two sync loops per sync frequency | ||
Two sync loops may be invoked per sync frequency if the server-side sync frequency | ||
differs from the client-side frequency. | ||
sync.api.init('myDataset', { | ||
syncFrequency: 10 // seconds | ||
}, function() {}); | ||
}); | ||
``` | ||
|
||
This is because the client and server sync frequencies are set independently. | ||
Setting a long frequency on a client does not change the sync frequency on the | ||
server. | ||
*TODO* | ||
|
||
The `syncFrequency` value of the dataset on the server should be set to the | ||
`sync_frequency` value of the corresponding dataset on the client to avoid this. | ||
* mounting routes in an express application that `invoke` sync on demand | ||
* hooking up a FeedHenry Data Syncronisation Client to the server | ||
|
||
For example: | ||
* `sync_frequency` on the client-side dataset is also set to 120 seconds. | ||
* `syncFrequency` on the server-side dataset is set to 120 seconds. | ||
## Tests | ||
In order to run the tests, please make sure you have [Docker](https://www.docker.com/) installed. | ||
|
||
## API logging | ||
Before running tests do: | ||
|
||
Users of the fh-mbaas-api can then enable logging if they would like to see more output. This is useful for debugging purposes. | ||
It's possible to pass environment variables to enable the logging according the rules specified for [debug](https://www.npmjs.com/package/debug) module: | ||
|
||
``` | ||
DEBUG="fh-mbaas-api:*" ./yourscript | ||
npm install | ||
npm install -g grunt-cli | ||
``` | ||
If `DEBUG_COLORS=0` is passed also it will print log messages with proper timestamps. This is automatically enabled outside properly supported terminal. | ||
|
||
Then to run the tests use ```npm test``` | ||
|
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,14 @@ | ||
var sync = require('../lib'); | ||
|
||
var mongodbConnectionString = 'mongodb://127.0.0.1:27017/sync'; | ||
var redisUrl = 'redis://127.0.0.1:6379'; | ||
|
||
sync.api.connect(mongodbConnectionString, {}, redisUrl, function(){}); | ||
|
||
sync.api.getEventEmitter().on('sync:ready', function() { | ||
console.log('sync ready'); | ||
|
||
sync.api.init('myDataset', { | ||
syncFrequency: 10 // seconds | ||
}, function() {}); | ||
}); |
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
8 changes: 4 additions & 4 deletions
8
...gration/sync/test_datasetClientCleaner.js → integration/test_datasetClientCleaner.js
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
2 changes: 1 addition & 1 deletion
2
...ration/sync/test_interceptor_overrides.js → integration/test_interceptor_overrides.js
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
6 changes: 3 additions & 3 deletions
6
integration/sync/test_mongodbQueue.js → integration/test_mongodbQueue.js
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
4 changes: 2 additions & 2 deletions
4
integration/sync/test_storage.js → integration/test_storage.js
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
6 changes: 3 additions & 3 deletions
6
integration/sync/test_sync_apis.js → integration/test_sync_apis.js
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.