Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
loopback-connector-remote
Advanced tools
The remote connector enables you to use a LoopBack application as a data source via REST. You can use the remote connector with a LoopBack application, a Node application, or a browser-based application that uses LoopBack in the client. The connector uses Strong Remoting.
In general, using the remote connector is more convenient than calling into REST API, and enables you to switch the transport later if you need to.
Use loopback-connector-remote:
In your application root directory, enter:
$ npm install loopback-connector-remote --save
This will install the module and add it as a dependency to the application's package.json
file.
Create a new remote data source with the datasource generator:
$ lb datasource
When prompted:
This creates an entry in datasources.json
; Then you need to edit this to add the data source properties, for example:
{% include code-caption.html content="/server/datasources.json" %}
...
"myRemoteDataSource": {
"name": "myRemoteDataSource",
"connector": "remote",
"url": "http://localhost:3000/api"
}
...
The url
property specifies the root URL of the LoopBack API.
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 myRemoteDataSource 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 the model foo
exposes a remote method called bar
,
the connector will automatically generate the following:
app.datasources.myRemoteDataSource.models.foo.bar()
To access the remote Loopback service in a model:
module.exports = function(Message) {
Message.test = function (cb) {
Message.app.datasources.myRemoteDataSource.models.
SomeModel.remoteMethodNameHere(function () {});
cb(null, {});
};
};
Property | Type | Description |
---|---|---|
host | String | Hostname of LoopBack application providing remote data source. |
port | Number | Port number of LoopBack application providing remote data source. |
root | String | Path to API root of LoopBack application providing remote data source. |
url | String | Full URL of LoopBack application providing remote connector. Use instead of host, port, and root properties. |
The remote connector does not support JSON-based configuration of the authentication credentials (see issue #3). You can use the following code as a workaround. It assumes that your data source is called "remote" and the AccessToken id is provided in the variable "token".
app.dataSources.remote.connector.remotes.auth = {
bearer: new Buffer(token).toString('base64'),
sendImmediately: true
};
When using the MongoDB connector on the server and a remote connector on the client,
use the following id
property:
"id": {
"type": "string",
"generated": true,
"id": true
}
FAQs
Remote REST API connector for Loopback
The npm package loopback-connector-remote receives a total of 13,928 weekly downloads. As such, loopback-connector-remote popularity was classified as popular.
We found that loopback-connector-remote demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 17 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.