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
Proposed restructuring for removal of fh-mbaas-express issue #2 #6
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I like idea of single simplified server file instead of full app in #1
Going to extend it a little bit after merge.