LoopBack remote REST API connector
Go to file
Miroslav Bajtoš e19cddd343 test: fix deprecation warnings 2016-09-01 10:47:13 +02:00
lib update copyright notices and license 2016-05-06 12:02:21 -07:00
test test: fix deprecation warnings 2016-09-01 10:47:13 +02: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 Start development of 2.x 2016-09-01 09:39:02 +02:00
CHANGES.md 1.3.2 2016-09-01 09:35:24 +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 Start development of 2.x 2016-09-01 09:39:02 +02:00
index.js update copyright notices and license 2016-05-06 12:02:21 -07:00
package.json Start development of 2.x 2016-09-01 09:39:02 +02:00

README.md

loopback-connector-remote

Remote REST API connector for loopback-datasource-juggler.

  • The version range 2.x is compatible with LoopBack v3 and newer.
  • Use the older range 1.x for applications using LoopBack v2.

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, {});
	};

};