Tag: sails.js

Sails js ::testing传递给视图的variables

调节器 module.exports = { index: function (req, res) { res.view({message: 'hello'}); } } 如何testingvariablesmessage是否设置正确? var request = require('supertest'); describe('HomeController', function() { describe('index', function() { it('should return success', function (done) { request(sails.hooks.http.app) .get('/') .expect(200).end(function (err, res) { if (err) throw err; res.body.should.have.property('message'); done(); }); }); }); }); res.body返回{}

启动sailsJS项目时更改环境

我在sailsjs项目中有两个环境:开发和生产。 在local.js中我有这样的: module.exports = { port: process.env.PORT || 1349, environment: process.env.NODE_ENV || "production" } 在我的development.js中我有: module.exports = { models: { connection: "someMongoDb", migrate: 'alter', schema : true, autoPK: true, autoCreatedAt: true, autoUpdatedAt: true }, port: 1348 } 在我的production.js中我有: module.exports = { models: { connection: "mongoDBPro", migrate: 'alter', schema : true, autoPK: true, autoCreatedAt: true, autoUpdatedAt: […]

Sails服务器未启动

我正在尝试使用以下命令来运行我的应用程序: forever start /var/www/app.js –prod 但是我有这个错误: To run an app using `node app.js`, you usually need to have a version of `sails` installed in the same directory as your app. To do that, run `npm install sails` Alternatively, if you have sails installed globally (ie you did `npm install -g sails`), you can use `sails […]

如何调用共享服务的function – SailsJS

我有服务: module.exports = { functionA: function () { sails.log('Hello!'); }, functionB: function () { functionA(); } } 那么我得到一个错误:“countPoint没有定义”作为标题,我想调用共享函数上的另一个函数,但我现在不怎么做。 谁能帮我? 对不起我英文不好〜

获取EACCES错误bower初始化

试图在一个资产文件夹上运行'bower init'我有一个小项目。 试图学习Sails.js框架,但希望凉亭来处理前端configuration。 下面的堆栈跟踪。 已经尝试调整访问path,但没有运气。 任何指针在正确的方向? 提前致谢 跟踪 $ bower init /Users/lukeduncan/.nvm/versions/io.js/v1.6.2/lib/node_modules/bower/node_modules/insight/node_modules/configstore/index.js:46 throw err; ^ Error: EACCES: permission denied, open '/Users/lukeduncan/.config/configstore/insight-bower.json' You don't have access to this file. at Error (native) at Object.fs.openSync (fs.js:546:18) at Object.fs.readFileSync (fs.js:396:15) at Object.create.all.get (/Users/lukeduncan/.nvm/versions/io.js/v1.6.2/lib/node_modules/bower/node_modules/insight/node_modules/configstore/index.js:27:26) at Object.Configstore (/Users/lukeduncan/.nvm/versions/io.js/v1.6.2/lib/node_modules/bower/node_modules/insight/node_modules/configstore/index.js:20:44) at new Insight (/Users/lukeduncan/.nvm/versions/io.js/v1.6.2/lib/node_modules/bower/node_modules/insight/lib/index.js:37:34) at ensureInsight (/Users/lukeduncan/.nvm/versions/io.js/v1.6.2/lib/node_modules/bower/lib/util/analytics.js:38:23) at Object.setup (/Users/lukeduncan/.nvm/versions/io.js/v1.6.2/lib/node_modules/bower/lib/util/analytics.js:55:9) at Object.<anonymous> […]

如何在Sails.js中使用水线运行自定义查询?

我正在寻找一种方法来在Sails.js中使用水线运行自定义查询。 例如,我想创build一个视图,例如: CREATE VIEW …通过某种模型(如User.query()运行它是没有意义的。 有没有办法运行原生查询,而不引用一些特定的模型?

帆JS + Angular JS:路由

我目前正在学习SailsJS,而我是Angular的用户。 我知道Angular可以和SailsJs毫无问题地共同工作(Sails回来了,Angular是前面的),它可以在我的应用上成功运行。 另一方面,我不确定路由:Angular的路由器必须呈现唯一的视图,而Sails的路由器必须呈现API REST路由? 或者所有路线都是由Angular或Sails生成的? 我使用这个教程,但我很尴尬,Angular处理所有的路由。 问候,

如何在MySQL中插入多个logging/行

在Sails.js中可以插入多个logging吗? 我正在使用MySQL,我需要根据来自API的请求将“n”行保存到MySQL中。 我需要关于Sails.js的帮助谢谢

sails.js – 更改公用文件夹不同于.tmp / public

我重新修改了sails.js资产stream量以适应我的需求。 我正在将我的公共资产存储在/ assets / dist中。 有没有简单的方法来configurationsails应用程序使用我自己的公用文件夹,而不是默认的“/.tmp/public”? 我知道可以通过/config/local.js来configuration这个选项,但我想在其他地方configuration(如果可能的话),所以它不会仅仅与当前机器相关,它将被包含在git仓库中。

处理promisses和服务器响应的正确方法

我正在尝试改进我在node.js / sail.js中的代码,并且正在与promisses中的服务器响应作斗争。 当你看第一个.then函数时,你可以看到该方法在forbidden access或false的情况下返回false 。 然后,在接下来的函数中,我必须检查返回types是否为=== false以跳过部分并避免发送两次http头。 这可以改善某些方面,跳过所有的下一个方法,如果失败的话? 我可以抛出一个exception进入最后一个.catch但必须有一个case之间切换所有可能的状态。 (即禁止,serverError甚至没有find) Notification.findOne({id: req.param('id')}) .then(function(notification) { if (!notification) { res.notFound(); return false; } if (notification.triggeredBy != req.session.user.id) { res.forbidden(); return false; } return notification; }) .then(function(notification) { if (notification === false) { return false; } return Notification.update(notification.id, actionUtil.parseValues(req)); }) .then(function(notification) { if (notification === false) { […]