loopbackjs

How can I use body-parser with LoopBack?

别说谁变了你拦得住时间么 提交于 2019-12-18 11:07:31
问题 I see that LoopBack has the Express 3.x middleware built-in. Indeed, body-parser is in loopback/node_modules . But I cannot figure out how to use it as middleware. I have never worked with Express 3.x, so maybe it's just that. require does not work, obviously, unless I install body-parser as a dependency in my project. What should I do in server.js to use body-parser so that web forms are parsed into req.params ? That's what it does, right? 回答1: After hours of frustration, I just added it to

How can I use body-parser with LoopBack?

醉酒当歌 提交于 2019-12-18 11:07:03
问题 I see that LoopBack has the Express 3.x middleware built-in. Indeed, body-parser is in loopback/node_modules . But I cannot figure out how to use it as middleware. I have never worked with Express 3.x, so maybe it's just that. require does not work, obviously, unless I install body-parser as a dependency in my project. What should I do in server.js to use body-parser so that web forms are parsed into req.params ? That's what it does, right? 回答1: After hours of frustration, I just added it to

How to Modify the StrongLoop's LoopBack Explorer CSS

落花浮王杯 提交于 2019-12-17 19:16:42
问题 We're using Strongloop's LoopBack for our REST APIs and would like to modify the CSS for the LoopBack Explorer. However, it's not clear which CSS files are being used (LoopBack vs Swagger) and where they're located. I was not able to find specific documentation for this. 回答1: You can provide your own version of Swagger UI files via options.uiDirs . Edit your server/server.js and add this config option to the explorer: app.use(explorer(app, { uiDirs: path.resolve(__dirname, 'explorer') }));

How can i return status inside the promise?

*爱你&永不变心* 提交于 2019-12-17 03:44:11
问题 I started to learning promise with loopback and jsforce, and couldn't handle this problem; I couldn't return status var inside promise to cb() function. Basically i want to connect salesforce and get data via JSforce and write it to db via loopback. Then want to return created/updated/error records to client after remote mothed called. I'm developing with Loopback via using Node.JS & Express.js I'm using JSforce library to connect salesforce How can I fix that? Here is my code: module.exports

LoopBack 4 - why it was published if its not a finished product

若如初见. 提交于 2019-12-14 04:05:17
问题 I have experience with Sequelize and TypeORM. LoopBack looks like a good alternative, so I tested it. But it looks like LoopBack 4 is not a finished product; it barely has the needed features for a production application. My question is: why the LoopBack team decided to publish an unfinished product? 回答1: there are a lot of companies and products on live using Loopback4. Which features you missed from the new version? 回答2: I mean, the product is free, open source and built off of previously

accessing current logged in user id in custom route in loopback

蹲街弑〆低调 提交于 2019-12-14 02:35:20
问题 I am trying to access the currently logged in user in a custom route using context.options but find it blank. Trying to access in a operational hook 'before save' like this: 'use strict'; module.exports = function (logs) { logs.observe('before save', async (ctx, next) => { console.log(ctx.options) //this is empty i.e {} }); Here is my custom route (boot script - routes.js): app.get('/logs/dl',(req,res)=>{ logs.create(logs,(err,obj)=>{ if(!err) { res.status(200); res.send(obj); } else { res

How to have service layer in loopback just like in other popular mvc frameworks?

雨燕双飞 提交于 2019-12-14 02:04:07
问题 I have started building an application in sailsjs but I decided to move it to loopback. From a j2ee/spring mvc background I was quickly up and running with sailsjs with some of my business logic in the api/service. Unfortunatly I have not found a way to create those services on loopback. I am not talking about remote method. These services are not really tied to any model, they are on a layer above models. I have tried creating the following at server/service/DataModelService.js module

Loopback getting error - Major change in User validatePassword function in the same release itself (3.0.0)

不想你离开。 提交于 2019-12-13 20:23:47
问题 I am using loopback 3.0.0, and I have set up a new server recently, about one week ago. For that, I have ran the command npm install by putting the package.son file. But in that installed files, the node_modules/loopback/common/user.js module has changed with major changes. Egs: Old file: // Copyright IBM Corp. 2014,2016. All Rights Reserved. User.validatePassword = function(plain) { var err; if (plain && typeof plain === 'string' && plain.length <= MAX_PASSWORD_LENGTH) { return true; } if

Something should be wrong with applying of “getter” methods in model-builder.js

混江龙づ霸主 提交于 2019-12-13 10:26:34
问题 I am trying to set-up some basic scenarios and use LoopBack to find out its actual level of flexibility and usability. One of them is the necessity to modify the value of some attributes in resulted JSON objetcs during processing the source data from a db (e.g. MySQL). I am using the following versions: strong-cli v2.5.5 (node v0.10.29) node-inspector v0.7.4 strong-build v0.1.0 strong-cluster-control v0.4.0 strong-registry v1.1.0 strong-supervisor v0.2.3 (strong-agent v0.4.9, strong-cluster

StrongLoop: POST access not being blocked

百般思念 提交于 2019-12-13 07:16:57
问题 I'm using ACL rules to block all types of accesses from all the users. It is working for GET access but it is NOT working for POST accesses. Any idea what could be wrong? Here is the code and sample results: /common/models/client.json { "name": "client", "plural": "clients", "base": "User", "idInjection": true, "properties": {}, "validations": [], "relations": {}, "acls": [ { "accessType": "*", "principalType": "ROLE", "principalId": "$everyone", "permission": "DENY" } ], "methods": {} } GET