sails.js

npm run custom-tests - sendHttpRequest failed non200Response

梦想的初衷 提交于 2020-01-16 16:08:25
问题 I'm trying to setup some SailsJS boilerplate I'm finding on the web. My code is below, I am thinking it is due to my config in routes where I set: 'GET /.temporary/csrf/token/for/tests': { action: 'security/grant-csrf-token' } I don't have any thing in api/controllers/ for security/grant-csrf-token , do I have to generate such a thing? const sails = require('sails'); before(function(done) { // Increase the Mocha timeout so that Sails has enough time to lift, even if you have a bunch of assets

Unique doesn't work on Node.js Sails.js “sails-mysql”

天大地大妈咪最大 提交于 2020-01-16 01:42:47
问题 I've just started to get into the framework of Sails for Node. But it seems like I can't get the unique- requirements to work when adding for example users to the sails-mysql database. I can atm add unlimited number of new users with the same username and email. From what I have read it should work, I did also try with sails-memory and there this exact code did work. Is it something I have missed out? module.exports = { attributes: { username: { type: 'string', required: true, unique: true },

Bind sails.js app to a specific ip

女生的网名这么多〃 提交于 2020-01-16 00:28:24
问题 I have a Nodejs project and is using sails.js mvc framework. Now, Im ready to deploy it, but before that one requirement is to bind it to a different ip. Is there a way on sails.js that we can achieve this? What file or config should I update? 回答1: You have to change the 'host' key. Source You can change the /config/local.js file and add the 'host' key to it : { port: '1234', host: '111.111.111.111', environment: 'production' } Source 回答2: I've tried @xShirase answer and it worked too. So I

How can I validate a record only without saving in nodejs | sailsjs | waterline

孤者浪人 提交于 2020-01-15 08:41:26
问题 I seek something of this nature //validation rules in model "User" attributes: { age: { required: true, type: 'numeric' } }, //now in controller, i want to be able to do this Recipe.validate({age: 'An invalid age because it is a string. I except a validation error as response'}); Problem is, it doesn't work.. it complains about beforeValidate not being available, e.t.c 回答1: You need to pass a callback into .validate : Recipe.validate({age: 'blah'}, function(err){ if (err && err

Sails.js + Postgres: issue with transactions

元气小坏坏 提交于 2020-01-15 05:43:53
问题 I am trying to implement a transaction in Sails 0.10.5 using Postgres as database, but the operations are not committed (or rolled back) at the end. This is a simple transaction scenario I wrote down as a test (using async.js): testTransaction: function(uri) { var testFile = { uri: uri, details: { 'firstDetail': 'value' } }; async.auto({ begin_transaction: function(callback) { DataFile.query('BEGIN TRANSACTION;', callback); }, new_data_file: ['begin_transaction', function(callback) { DataFile

How to properly throw and handle errors in promises in Sails.js?

喜你入骨 提交于 2020-01-14 09:20:09
问题 I'm starting to convert my callback code to promises in Sails.js, but I don't understand how I can raise custom errors and handle them in the promise chain. Sails.js uses Q as its promise library. User.findOne({email: req.param('professorEmail'), role: 'professor'}) .then(function (user) { if (user) { return Course.create({ user_id: user.id, section: req.param('section'), session: req.param('session'), course_code: req.param('course_code') }); } else { // At this point `user` is undefined

How to properly throw and handle errors in promises in Sails.js?

余生颓废 提交于 2020-01-14 09:19:09
问题 I'm starting to convert my callback code to promises in Sails.js, but I don't understand how I can raise custom errors and handle them in the promise chain. Sails.js uses Q as its promise library. User.findOne({email: req.param('professorEmail'), role: 'professor'}) .then(function (user) { if (user) { return Course.create({ user_id: user.id, section: req.param('section'), session: req.param('session'), course_code: req.param('course_code') }); } else { // At this point `user` is undefined

How to properly throw and handle errors in promises in Sails.js?

纵饮孤独 提交于 2020-01-14 09:18:41
问题 I'm starting to convert my callback code to promises in Sails.js, but I don't understand how I can raise custom errors and handle them in the promise chain. Sails.js uses Q as its promise library. User.findOne({email: req.param('professorEmail'), role: 'professor'}) .then(function (user) { if (user) { return Course.create({ user_id: user.id, section: req.param('section'), session: req.param('session'), course_code: req.param('course_code') }); } else { // At this point `user` is undefined

nginx / sails.js: incomplete file upload

ぃ、小莉子 提交于 2020-01-14 05:10:12
问题 We are developing an app using sails.js. In this app we have an upload controller: https://github.com/makinacorpus/mnhn_bai/blob/master/api/controllers/Object3DController.js This controller use skipper under the hood, as explained in the documentation. Now the problem is that when we upload big files, they are incompletely stored, the uploaded size is never the same and varies from 7mb to 14mb for a 15 mb file. The architecture is as follow: haproxy -> nginx -> node.js/sails. If we replace

Deploy sails.js to Windows Azure Website

一笑奈何 提交于 2020-01-13 20:02:14
问题 I'm following this guide on installing a node.js application on Azure: http://www.windowsazure.com/en-us/develop/nodejs/tutorials/create-a-website-(mac)/#header-0 Is it possible to get a sails.js app running without having to instantiate a Virtual Machine? 回答1: As of right now sails requires an npm install -g on the box which would require either a virtual machine or a cloud service with a startup script. The link you are showing if for a deployment model where you don't get any access to