strongloop

Dynamically adding user to a loopback Role

拥有回忆 提交于 2019-12-09 07:14:25
问题 I have been studying the loopback / Strongloop documentation and it is not clear to me that it is possible to dynamically add a new user to a role (i.e. add a user to role via role-mapping), that is, without the need to restart the API. Can anyone confirm one way or the other? (ideally, but not necessarily, pointing me to some documentation or example to confirm or not that this is doable). Thanks much. 回答1: You can create rolemappings for users in strongloop with something like this - Role

Auto-create mysql table with StrongLoop

怎甘沉沦 提交于 2019-12-09 05:14:33
问题 I am trying to use Strongloop with MySql but cannot figure out how to migrate or automatically create tables into a MySql database. Is there at least a way to export the models into MySql schemas or do I have to manually create the tables? I've been trying with the mysql demo app, and going over the docs for a while but no luck - http://docs.strongloop.com/display/DOC/MySQL+connector Thanks! 回答1: LoopBack calls it auto-migration. Check these links and search for that term: Recipes for

Level 2 (related model) scope over REST - strongloop api

本秂侑毒 提交于 2019-12-09 01:24:47
问题 I found in the documentation that scopes enable you to specify commonly-used queries that you can reference as method calls on a model. Below i have a categories model. I am trying to create scopes that applies to the relation with model games . Unfortunately the below does nothing. How can I get scopes to apply to relation as shown below? GET /Categories/{id}/games - This gets all games common/models/category.json "relations": { "categories": { "type": "hasMany", "model": "game", "foreignKey

strongloop, how to define a response class for a custom endpoint

£可爱£侵袭症+ 提交于 2019-12-08 21:46:26
According to the documentation you can create custom response classes; https://docs.strongloop.com/display/public/LB/Remote+methods#Remotemethods-Argumentdescriptions The remote method description I use is: common/models/products-sku.js ProductsSku.remoteMethod( 'getSomeData', { http: {path: '/getSomeData', verb: 'get'}, accepts: {arg: 'filter', type: 'object', http: { source: 'query'} }, returns: { arg: 'id', description: 'Custom endpoint', type: 'CustomProductType', root: true } } ); In the same file I have a definition for the CustomProductType; var CustomProductType: { id: Number, name:

StrongLoop Loopback : How to customize HTTP response code and header

北慕城南 提交于 2019-12-08 19:06:50
问题 I'm looking for a way to customize StrongLoop LoopBack HTTP response code and headers. I would like to conform to some company business rules regarding REST API. Typical case is, for a model described in JSON, to have HTTP to respond to POST request with a code 201 + header Content-Location (instead of loopback's default response code 200 without Content-Location header). Is it possible to do that using LoopBack ? 回答1: Unfortunately the way to do this is a little difficult because LoopBack

Error: “Double colon in host identifer”

僤鯓⒐⒋嵵緔 提交于 2019-12-08 15:09:19
问题 I am trying to connect to a database that I have hosted at MLab. I am using the StrongLoop API. I've placed the config information for my hosted databases into my datasources.json and config.json files, but whenever I run the directory with npm start , I get throw new Error ('double colon in host identifier';) at api\node_modules\mongodb\lib\url_parser.js:45. I have also made sure to install the loopback-connecter-mongodb npm package. Here is a snippet of datasources.json (without the actual

StrongLoop: hiding method updateAttributes()

给你一囗甜甜゛ 提交于 2019-12-08 11:19:28
问题 I've managed to take out some of the predefined methods from my rest API using this code wich I adapted from the documentation: var app = require('../app'); var News = app.models.News; News.create.shared = false; News.upsert.shared = false; News.deleteById.shared = false; However, this same code breaks when I try to hide the updateAttributes() predefined method. Does anyone know how come this is? 回答1: You should do: News.prototype.updateAttributes.shared = false; 回答2: The one provided by

Permanent token on loopback

我怕爱的太早我们不能终老 提交于 2019-12-08 05:26:55
问题 I am building an app using Loopback API that will be consumed by an iPhone APP. There is a connection to a MySQL database where I run some queries to get some results and expose on the API. The endpoints contain an ACL that will allow only authenticated users to perform any operation, including the GET ones. So basically the requests need to be done using the ?access_token query string. I want to set a token that can be saved on the MySQL database and can be used "forever" on the API. I am

how does strongloop supervisor handle websocket connections?

ε祈祈猫儿з 提交于 2019-12-08 04:37:44
问题 I have a node app that I connect to from a browser using WebSockets. If I run this app under a supervisor ( slc run --cluster cpu myapp.js ), will a websocket connection be always forwarded to the same worker once established? Or will the supervisor do some sort of load balancing when forwarding messages send to this connection? 回答1: strong-supervisor does absolutely no load balancing or clustering on its own: it auto-starts and configures node cluster (http://nodejs.org/api/cluster.html)

strongloop, how to define a response class for a custom endpoint

☆樱花仙子☆ 提交于 2019-12-08 03:53:03
问题 According to the documentation you can create custom response classes; https://docs.strongloop.com/display/public/LB/Remote+methods#Remotemethods-Argumentdescriptions The remote method description I use is: common/models/products-sku.js ProductsSku.remoteMethod( 'getSomeData', { http: {path: '/getSomeData', verb: 'get'}, accepts: {arg: 'filter', type: 'object', http: { source: 'query'} }, returns: { arg: 'id', description: 'Custom endpoint', type: 'CustomProductType', root: true } } ); In the