LoopBack remote REST API connector
Go to file
Miroslav Bajtoš ed20519ce7 Merge pull request #79 from strongloop/add-travis
build: enable Travis CI
2017-10-17 14:37:26 +02:00
.github Add stalebot configuration 2017-08-22 13:14:17 -04:00
lib Use the new API for defining remoting types 2016-09-09 09:50:22 +02:00
test Add "options" arg to stubbed models in tests 2016-12-22 10:56:11 +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 13:29:59 +02:00
.travis.yml build: enable Travis CI 2017-10-17 14:25:32 +02:00
CHANGES.md 3.1.1 2016-12-21 16:03:43 +01:00
CODEOWNERS Add CODEOWNER file 2017-07-24 19:47:21 -04: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 Update package.json for LB3 release 2016-12-21 00:46:48 -08:00
index.js update copyright notices and license 2016-05-06 12:02:21 -07:00
package.json 3.1.1 2016-12-21 16:03:43 +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.

Learn more about our LTS plan in docs.

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

};