LoopBack remote REST API connector
Go to file
Miroslav Bajtoš 69ebd5f931 Merge pull request #72 from strongloop/fix/computed-options-arg-1x
Add "options" arg to stubbed models in tests
2016-12-22 12:00:41 +01:00
lib update copyright notices and license 2016-05-06 12:02:21 -07:00
test Add "options" arg to stubbed models in tests 2016-12-22 11:14:45 +01:00
.editorconfig Move remote connector from loopback 2014-09-25 14:20:22 -07:00
.eslintrc Move remote connector from loopback 2014-09-25 14:20:22 -07:00
.gitignore Move remote connector from loopback 2014-09-25 14:20:22 -07:00
.jshintignore Move remote connector from loopback 2014-09-25 14:20:22 -07:00
.jshintrc Clean up tests 2016-01-07 20:08:05 -08:00
.npmignore Update dev-dependencies 2016-09-01 16:48:04 +02:00
CHANGES.md 1.3.3 2016-09-01 09:53:16 +02:00
CONTRIBUTING.md Update URLs in CONTRIBUTING.md (#50) 2016-07-13 17:33:12 -07:00
Gruntfile.js Do not use native promises in tests 2016-05-19 18:04:23 -07:00
LICENSE update copyright notices and license 2016-05-06 12:02:21 -07:00
README.md Add info about LoopBack version compatibility 2016-09-01 09:52:46 +02:00
index.js update copyright notices and license 2016-05-06 12:02:21 -07:00
package.json Update package.json for LB2 LTS release 2016-12-21 00:48:54 -08:00

README.md

loopback-connector-remote

Remote REST API connector for loopback-datasource-juggler.

  • The version range 1.x is compatible with LoopBack 2.x.
  • Use the upcoming versions 2.x for applications using LoopBack 3.x.

Quick Explanation

Use this connector to create a datasource from another Loopback application. Below is a quick example:

datasource.json

	"MyMicroService": {
		"name": "MyMicroService",
		"connector": "remote"
	}

Note that you should add a url property to point to another remote service. If you do not specify a url property, the remote connector will point to it's own host name, port it's running on, etc.

The connector will generate models on the MyMicroService datasource object based on the models/methods exposed from the remote service. Those models will have methods attached that are from the model's remote methods. So if you exposed a remote method from that micro-service called bar from the model foo, the connector will automatically generate the following:

app.datasources.MyMicroService.models.foo.bar()

Access it in any model file

To access the remote Loopback service in a model:

module.exports = function(Message) {

	Message.test = function (cb) {
		Message.app.datasources.MyMicroService.models.SomeModel.remoteMethodNameHere(function () {});

		cb(null, {});
	};

};