LoopBack remote REST API connector
Go to file
Miroslav Bajtoš 1506a5039e 3.1.0
* Drop support for Node v0.10 and v0.12 (Miroslav Bajtoš)
 * Fix version info in README (Miroslav Bajtoš)
 * Update deps to loopback 3.0.0 RC (Miroslav Bajtoš)
2016-12-05 10:16:31 +01:00
lib Use the new API for defining remoting types 2016-09-09 09:50:22 +02:00
test Update to juggler@3 and remoting@3 2016-09-01 12:58:16 +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 Update dev-dependencies 2016-09-01 13:29:59 +02:00
CHANGES.md 3.1.0 2016-12-05 10:16:31 +01: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 Fix version info in README 2016-10-17 13:05:53 +02:00
index.js update copyright notices and license 2016-05-06 12:02:21 -07:00
package.json 3.1.0 2016-12-05 10:16:31 +01:00

README.md

loopback-connector-remote

Remote REST API connector for loopback.

  • The version range 3.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, {});
	};

};