Tag: sails.js

Node.js使用http postlogin并在login后获取数据

如何使用Node.js http POST,GET执行以下操作? login到abc.com(这是一个带login表单的login页面) 在login后的页面中,使用POST填充另一个表单,并在发布表单后获取结果。

如何编写一个path,以path参数为目标

如果我有多个像“/ some / url / path / foo / bar1”,“/ some / url / path / foo / bar2”,“/ some / url / path / foo / bar3”等。一个单一的路线,将指挥的url到foo控制器和bar1,bar2,bar3等的动作 例如。 (只有这个不行。) '/ some / url / path / foo /:bar':'foo.:bar'

如何在SailsJs中使用debugging包

我正在使用SailsJs应用程序,并使用console.log进行debugging。 我正在尝试使用npm包debugging来达到这个目的。 https://www.npmjs.com/package/debug 但是,在阅读了解释和例子之后,我不知道如何使用它: “通过debugging,您只需调用导出的函数来生成您的debuggingfunction,传递一个名称来决定是否返回一个noop函数,或者是一个装饰的console.error,所以所有的控制台格式string好东西,你习惯于工作没问题,每个function都select一种独特的颜色来提高可视性。“ 我无法理解这一点。 例如,我有UserController.js,我需要启用debugging。 我应该使用还是别的? var debug=require('debug')('UserController');

Sails JS Blueprints允许在主键上进行更新操作

Sails JS使用蓝图为定义的模型创buildCRUD。 要做一个更新你做Model / Update /:id,然后传入你想改变的值。 但是,这允许更改主键。 有没有办法禁止这个没有定义自定义CRUD?

运行node.js在openshift上运行应用程序

我试图在openshift上部署我的node.js sails应用程序。 我遵循https://gist.github.com/mdunisch/4a56bdf972c2f708ccc6中列出的程序,但仍然无法正常工作。 也试试这个: 在openshift Node.js应用程序 不pipe我得到什么“服务暂时不可用”由于维护停机或容量问题,服务器暂时无法处理您的请求。 请稍后再试。 错误。 希望至less有人能指出我正确的方向。 提前致谢。

如何在模型的属性方法中正确使用水线承诺?

在Model我使用的属性方法将查找数据库,不得不查询其他不同的模型。 所以我使用水线承诺,但我不知道如何实际执行模型的属性方法本身的返回方法,这就是我正在做的: 我们称之为LineUp模型: module.exports = { connection: 'seasonDB', attributes: { reachesMaxFavoriteTeam: function (team) { UserTeam.findOne(). where({id: this.userTeam}). then(function (team) { User.findOne(). where({id: team.userId}). then(function (user) { return [team, user.fanOf]; // I assume to be returning for the spread function }). spread(function (team, user) { // How can I make reachesMaxFavoriteTeam return something here??? }).catch(function (err) […]

findOne没有得到任何logging

login: function (req, res) { var username = req.param('username'); var password = req.param('password'); User.findOne({username: username}, function (err, user) { if (err || !user) { return res.status('401').send("User with username \"" + username + "\" not found. Are you registered?"); } … 给我undefined的user对象,我总是在错误语句结束。 usernamevariables具有正确的值。 我创buildlogging的方法是有效的(所以我和DB的连接是正常的),当我查看数据库时,logging在那里,所有正确的数据。 我也试过User.find().where({username: username}).exec(function (err, user) {没有成功… 任何有关我可以在哪里查看(debugging或排除)或者可能是问题原因的build议?

SailsJS中的自定义logging器

下面是我的log.js文件,但它只logging“彩色winston你好”,但它没有logging我的应用程序中的所有我的sails.log.info。 我究竟做错了什么。 我到处search,无法弄清楚。 所有我发现是这个https://groups.google.com/forum/#!topic/sailsjs/67u7SqzsNJQ ,似乎证实我做得很对。 var winston = require('winston'), Papertrail = require('winston-papertrail').Papertrail; var logger = new winston.Logger({ transports: [ new Papertrail({ host: 'logs3.papertrailapp.com', port: xxxxx, // my port here colorize: true }) ] }); logger.info('Hello from colorized winston', logger); module.exports = { log: { custom: logger } }; 任何帮助将不胜感激。 PS。 我正在跳进一个由别人创build的项目,所以有可能他们破坏了一些东西。 如果有人能通过告诉我如何debugging自定义作品,如何debugging也是值得赞赏的。

调用保存方法后Sails没有任何事情发生

对不起,这是我的第一个nodeJs应用程序,我正在使用SailsJs,这是我的代码 update: function (req, res) { Cargo.findOne({id: req.param('id')}).exec(function (err,result) { result.currency = 2; if(err) { console.log(err); } result.save(function(err,model){ console.log(err); console.log(model); console.log('in'); }); console.log("testing"); }) }, 我一直在我的控制台日志中“testing”,并没有得到任何login保存方法。 我做错了吗?

帆生成oauth

我跟随这个链接sails-generate-oauth来产生oauth与风帆,我遵循,并作出所有的步骤,如在引用页面说,但我得到这个错误: root@Ubuntu:~/sailTests/guatour# sails lift info: Starting app… /root/sailTests/guatour/config/routes.js:50 'get /login': 'AuthController.login', ^^^^^^^^^^^^ SyntaxError: Unexpected string at exports.runInThisContext (vm.js:73:16) at Module._compile (module.js:443:25) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Module.require (module.js:365:17) at require (module.js:384:17) at /usr/local/lib/node_modules/sails/node_modules/include- all/index.js:129:29 at Array.forEach (native) at requireAll (/usr/local/lib/node_modules/sails/node_modules/include-all/index.js:44:9) at buildDictionary (/root/sailTests/guatour/node_modules/sails/node_modules/sails-build-dictionary/index.js:68:14) at Function.module.exports.aggregate (/root/sailTests/guatour/node_modules/sails/node_modules/sails-build-dictionary/index.js:190:9) at Array.loadOtherConfigFiles (/root/sailTests/guatour/node_modules/sails/lib/hooks/moduleloader/index.js:164:27) at […]