sails

How to use external rest api in Sails js (nodejs MVC)

匿名 (未验证) 提交于 2019-12-03 07:36:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Im using sailsjs as a MVC for node js, i'm still learning it. I managed to get data from my own database and use it. But now i need/want to get data from an external rest api. I used this in my controller: // api/controllers/SomeController.js test : function(res,req){ var j; var https = require('https'); var options = { hostname: 'testing.atlassian.net', port: 443, path: '/rest/api/2/search?jql=project=ABC', method: 'GET', headers: {'Authorization': 'Basic ' + 'SuperSecretLoginAndPassword'} }; var req = https.request(options, function(res) {

SailsJS - using sails.io.js with JWT

匿名 (未验证) 提交于 2019-12-03 02:52:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have implemented an AngularJS app, communicating with Sails backend through websockets, using sails.io.js. Since the backend is basically a pure API and will be connected to from other apps as well, I'm trying to disable sessions completely and use JWT. I have set up express-jwt and can use regular HTTP requests quite nicely, but when I send a request through sails.io.js, nothing happens at all - websocket request keeps pending on the client, and there's nothing happening on the server (with "silly" log level). I've tried patching sails.io

Auto reloading a Sails.js app on code changes?

匿名 (未验证) 提交于 2019-12-03 02:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Currently is seems that for any code change in a sails.js app you have to manually stop the sails server and run sails lift again before you can see the changes. I was wondering if there is any way when running in development mode to automatically restart the sails server when it detects a code change? 回答1: You have to use a watcher like forever , nodemon , or something else... Example Install forever by running: sudo npm install -g forever Run it: forever -w start app.js To avoid infinite restart because Sails writes into .tmp folder, you

MongoError: topology was destroyed sailsjs

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When I try to create this error shows up: Error (E_UNKNOWN) :: Encountered an unexpected error MongoError: topology was destroyed at Server.insert (/Users/oscargallon/Documents/developer/sails/reyesmagoswebpae/node_modules/sails-mongo/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:797:49) here's my model module.exports = { attributes: { name: { type: 'string', required: true }, email: { type: 'String', required: true }, description: { type: 'string', required: true }, phonenumber: { type: 'string', required: true },

Sails.js associations

匿名 (未验证) 提交于 2019-12-03 01:02:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am beginning with sails.js and I am completely lost with my sql queries. I have the following tables : genres +-----------+--------------+------+-----+ | Field | Type | Null | Key | +-----------+--------------+------+-----+ | id | int(6) | NO | PRI | | name | varchar(100) | NO | | | slug | varchar(255) | NO | | | type | varchar(32) | NO | | | parent_id | int(11) | YES | MUL | +-----------+--------------+------+-----+ genres_radios +----------+--------+------+-----+ | Field | Type | Null | Key | +----------+--------+------+-----+ | genre_id

Sails基础之Model层的Lifecycle callbacks

匿名 (未验证) 提交于 2019-12-02 23:32:01
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xreztento/article/details/90269238 Lifecycle Sails Model的生命周期主要是值对于记录操作的生命周期: create->update->destroy Lifecycle callbacks指的是在上述生命周期到达或完成时的hook方法,包括以下内容: Callbacks on create beforeCreate: fn(recordToCreate, proceed) afterCreate: fn(newlyCreatedRecord, proceed) Callbacks on update beforeUpdate: fn(valuesToSet, proceed) afterUpdate: fn(updatedRecord, proceed) Callbacks on destroy beforeDestroy: fn(criteria, proceed) afterDestroy: fn(destroyedRecord, proceed) 该部分内容非常好理解,主要可以用于默认值生成、密码加盐、额外的关联计算操作等,举例如下: npm install node-uuid --save npm install