sails.js

NPM : how to source ./node_modules/.bin folder?

不羁岁月 提交于 2019-12-05 14:16:34
问题 I have a problem on npm installation I have created a project say project A cd ~/projectA npm install sails but sails command is not found after installation. I know that it is successfully install in ~/projectA/node_modules directory. but the executable cannot be sourced. And i know it is installed ~/projectA/node_modules/.bin How can I source the .bin automatically whenever I enter into this projectA folder? Did I did something wrong? 回答1: I can give you an inelegant solution, which is

Can't find records in Waterline by date/time

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 13:28:29
how compare a datetime in sails.js Model? here it is what i did but without luck. var _date = moment().format('YYYY-MM-DDTHH:mm:ss.SSS') + 'Z'; Game.find({ where:{ active: true, start: { '>=' : _date } }, limit: 1, sort: 'start asc' }, function(err, game) { console.log('ERROR: ' + err); console.log('Game OBJ' + game.toString()); }); The datetime type is transformed into an actual Javascript date in Waterline (the Sails ORM). So it needs to be compared against a date object, not a string. You can keep your code exactly as it is, but change the first line to: var _date = new Date(moment().format

Posting object array to sails causes 'TypeError: Cannot convert object to primitive value'

你说的曾经没有我的故事 提交于 2019-12-05 12:02:05
In my html page i am sending this post to my sails server but I cannot get to the data in my controller as the req.param() function does not return any meaningful answer. Here is the web page code $.post("http://myserver.local/calendar/batch", {"batch":[ { "start_date" : "2014-06-27T09:00:00Z", "title" : "abc", "attendees" : [ "Fred Bloggs", "Jimmy Jones", "The Queen" ], "event_id" : "123", "location" : "Horsham, United Kingdom", "end_date" : "2014-06-27T10:30:00Z" }, { "start_date" : "2014-06-27T09:00:00Z", "title" : "another", "attendees" : [ "Fred Bloggs", "Jimmy Jones", "The Queen" ],

Angular $http.delete request with body

心已入冬 提交于 2019-12-05 11:13:23
So I looked at this post: is an entity body allowed for an http delete request Which seems to indicate that while it is 'ok' to do on some conceptual level, in practice it may not be doable because browsers just ignore it. I have some express.js authentication middleware I need to get through, and I don't want to attach my user details to url params. All my other requests that need to authenticate attach these details to the body of the request. Is there some way to force this? I saw some other posts where some people seemed to have success in passing a body with their delete request. I am

Aborted upload causes Sails js/Skipper to crash

纵饮孤独 提交于 2019-12-05 11:12:59
Ref: https://github.com/balderdashy/skipper/issues/49 Adapter: skipper-gridfs Basic controller code: req.file('fileTest') .upload({ // You can apply a file upload limit (in bytes) maxBytes: maxUpload, adapter: require('skipper-gridfs'), uri: bucketConnect, saveAs : function (__newFileStream,cb) { cb(null, __newFileStream.filename); } }, function whenDone(err, uploadedFiles) { if (err) { var error = { "status": 500, "error" : err }; return res.serverError(error); }else { I have a jQuery-File-Upload client ( https://blueimp.github.io/jQuery-File-Upload/ ) impementing the "cancel" procedure by

sails: how to redirect after creating a model with the built-in crud operations?

半城伤御伤魂 提交于 2019-12-05 10:48:25
I'm dong some quick testing with the Sails framework for Node. I like the way default CRUD-operations work out of the box, once a model and a controller (e.g.: for user ) are created. I'm having a bit trouble with extending the basics though. Say: I've created a User-model and empty User-controller. This should give me default Rest and Crud operations. I've defined a user-signup form that does as POST to user/create . This functionality is defined out of the box. This works, but results in displaying the created JSON at user/create . How do I extend this to redirect to a certain url for

How to test controller using mocha in Sails?

南楼画角 提交于 2019-12-05 10:46:02
I have the following Controller for my login page: // Authentication Controller // the basics of Passport.js to work. var AuthController = { // localhost:1337/login Render the login page // <form role="form" action="/auth/local" method="post"> // <input type="text" name="identifier" placeholder="Username or Email"> // <input type="password" name="password" placeholder="Password"> // <button type="submit">Sign in</button> // </form> login: function(req, res) { var strategies = sails.config.passport, providers = {}; // Get a list of available providers for use in templates. Object.keys

SailsJS and mySQL custom ID name not working with blue prints

╄→гoц情女王★ 提交于 2019-12-05 10:42:24
I created a new model in SailsJS with a custom id name as the primary key. I'd like to utilize the blue prints routes that come with SailsJS but when I try to go to /name/1 I get the error below. ER_BAD_FIELD_ERROR: Unknown column 'id' in 'where clause' It appears that Sails is still looking for the default table name 'id' instead of my new custom id. Any ideas on how to get Sails to realize my changes? Thank you Rahat Khanna Go to your model definition and add the autoPK:false at last. module.exports = { schema:'true', attributes: { propertyName: { type:"string", required:true, unique: true }

Integrating Sails Js with Angular 2

北战南征 提交于 2019-12-05 09:48:02
I'm trying to integrate Angular 2 in a Sails Js application. I'm new to both. I have been following this official tutorial here. It works fine in standalone mode with a static http server but when i try to integrate into sails app i get following problems: 1 - How do i refer to angular2 js inside the local node_modules folder. Everytime i do, sails interprets it as a route and gives me a 404 for my scripts. For instance: <script src="node_modules/angular2/dist/angular2.min.js"></script> I was able to overcome above issue using cdnjs links for now but i would like to know a better/proper

NodeJS best practices: Errors for flow control?

别说谁变了你拦得住时间么 提交于 2019-12-05 09:18:19
In Node.js, should I use errors for flow control, or should I use them more like exceptions? I'm writing an authentication controller and some unit tests in Sails.js, and currently, my registration method checks to see if a user with the same username exists. If a user already exists with the username, my model method calls its callback arguments with a new Error object, like so: Model: exists: function (options, cb) { User.findOne({ where: { username: typeof options === 'Object' && options.username ? options.username : options }, }).exec(function (err, user) { if (err) return cb(err); if