{"id":13749524,"url":"https://github.com/strongloop/loopback-example-offline-sync","last_synced_at":"2025-05-09T12:33:10.355Z","repository":{"id":15460913,"uuid":"18194030","full_name":"strongloop/loopback-example-offline-sync","owner":"strongloop","description":"Offline sync, change tracking, and replication.","archived":true,"fork":false,"pushed_at":"2020-03-05T15:00:30.000Z","size":2509,"stargazers_count":286,"open_issues_count":0,"forks_count":110,"subscribers_count":50,"default_branch":"master","last_synced_at":"2024-08-04T07:03:32.148Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://loopback.io/doc/en/lb2/Synchronization.html","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/strongloop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null}},"created_at":"2014-03-27T22:42:30.000Z","updated_at":"2024-07-31T17:25:40.000Z","dependencies_parsed_at":"2022-08-27T07:51:52.901Z","dependency_job_id":null,"html_url":"https://github.com/strongloop/loopback-example-offline-sync","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongloop%2Floopback-example-offline-sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongloop%2Floopback-example-offline-sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongloop%2Floopback-example-offline-sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongloop%2Floopback-example-offline-sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/strongloop","download_url":"https://codeload.github.com/strongloop/loopback-example-offline-sync/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224863107,"owners_count":17382279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T07:01:04.291Z","updated_at":"2024-11-16T00:30:46.464Z","avatar_url":"https://github.com/strongloop.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# loopback-example-offline-sync\n\n**⚠️ This LoopBack 3 example project is no longer maintained. Please refer to [LoopBack 4 Examples](https://loopback.io/doc/en/lb4/Examples.html) instead. ⚠️**\n\nAn example running LoopBack in the browser and server, demonstrating the\nfollowing features:\n\n - offline data access and synchronization\n - routes shared between the AngularJS app and the HTTP server\n\n## Install and Run\n\n0. You must have `node` and `git` installed. It's recommended to have `mongod`\n   installed too, so that the data is preserved across application restarts.\n\n1. Clone the repo.\n\n2. `cd loopback-example-offline-sync`\n\n3. `npm install` - install the root package dependencies.\n\n4. `npm install grunt-cli -g` - skip if you have Grunt CLI already installed.\n\n5. `npm install bower -g` - skip if you already have Bower installed.\n\n6. `bower install` - install front-end scripts\n\n7. `mongod` - make sure mongodb is running if you want to run with\n`NODE_ENV=production`.\n\n8. `grunt serve` - build and run the entire project in development mode.\n\n9. open `http://localhost:3000` - point a browser at the running application.\n\n## Project layout\n\nThe project is composed from multiple components.\n\n - `common/models/` contains definition of models that are shared by both the server\n  and the client.\n\n - `client/lbclient/` provides an isomorphic loopback client with offline synchronization.\n  The client needs some client-only models for data synchronization. These\n  models are defined in `client/lbclient/models/`.\n\n - `client/ngapp/` is a single-page AngularJS application scaffolded using `yo\n  angular`, with a few modifications to make it work better in the full-stack\n  project.\n\n - `server/` is the main HTTP server that brings together all other components.\n  Also сontains the REST API server; it exposes the shared models via\n  REST API.\n\n## Build\n\nThis project uses [Grunt](http://gruntjs.com) for the build, since that's what\n`yo angular` creates.\n\nThere are three major changes from the generic Gruntfile required for this\nfull-stack example:\n\n - `grunt serve` uses the `server/` component instead of `grunt connect`.\n\n - `lbclient` component provides a custom build script (`lbclient/build.js`)\n   which runs `browserify` to produce a single js file to be used in the\n   browser. The Gruntfile contains a custom task to run this build.\n\n - The definition of Angular routes is kept in a standalone JSON file\n   that is used by the `server/` component too. To make this JSON file\n   available in the browser, there is a custom task that builds\n   `ngapp/config/bundle.js`.\n\n### Targets\n\n - `grunt serve` starts the application in development mode, watching for file changes\n  and automatically reloading the application.\n - `grunt test` runs automated tests (only the front-end has tests at the\n   moment).\n - `grunt build` creates the bundle for deploying to production.\n - `grunt serve:dist` starts the application serving the production bundle of the\n   front-end SPA.\n - `grunt jshint` checks consistency of the coding style.\n\n## Adding more features\n\n### Define a new shared model\n\nThe instructions assume the name of the new model is 'MyModel'.\n\n 1. Create a file `models/my-model.json`, put the model definition there.\n  Use `models/todo.json` as an example, see\n  [loopback-boot docs](http://apidocs.strongloop.com/loopback-boot) for\n  more details about the file format.\n\n 2. (Optional) Add `models/my-model.js` and implement your custom model\n  methods. See `models/todo.js` for an example.\n\n 3. Add an entry to `rest/models.json` to configure the new model in the REST\n  server:\n\n    ```json\n    {\n      \"MyModel\": {\n        \"dataSource\": \"db\"\n      }\n    }\n    ```\n\n 4. Define a client-only model to represent the remote server model in the\n  client - create `lbclient/models/my-model.json` with the following content:\n\n    ```json\n    {\n      \"name\": \"RemoteMyModel\",\n      \"base\": \"MyModel\"\n    }\n    ```\n\n 5. Add two entries to `lbclient/models.json` to configure the new models\n  for the client:\n\n    ```json\n    {\n      \"MyModel\": {\n        \"dataSource\": \"local\"\n      },\n      \"RemoteMyModel\": {\n        \"dataSource\": \"remote\"\n      }\n    }\n    ```\n\n 6. Register the local model with Angular's injector in\n  `ngapp/scripts/services/lbclient.js`:\n\n    ```js\n      .value('MyModel', app.models.LocalMyModel)\n    ```\n\n### Create a new Angular route\n\nSince the full-stack example project shares the routes between the client and\nthe server, the new route cannot be added using the yeoman generator.\n\n 1. (Optional) Create a new angular controller using yeoman, for example,\n\n    ```sh\n    $ yo angular:controller MyModel\n    ```\n\n 2. (Optional) Create a new angular view using yeoman, for example,\n\n    ```sh\n    $ yo angular:view models\n    ```\n\n 3. Add a route entry to `ngapp/config/routes.json`, for example,\n\n    ```json\n    {\n      \"/models\": {\n        \"controller\": \"MymodelCtrl\",\n        \"templateUrl\": \"/views/models.html\"\n      }\n    }\n    ```\n\n---\n\n[More LoopBack examples](https://loopback.io/doc/en/lb3/Tutorials-and-examples.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrongloop%2Floopback-example-offline-sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstrongloop%2Floopback-example-offline-sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrongloop%2Floopback-example-offline-sync/lists"}