sails.js

Advantages of a separate REST backend API?

与世无争的帅哥 提交于 2019-12-19 04:33:11
问题 Context: I'm a beginner programmer, self taught in the hope of making a SPA. I've started with JavaScript, Jquery, PHP and MySQL, and now feel pretty confident with all. I've started with Ember, and am now moving away from having a PHP API to Node. Which has then brought me closer to Meteor... I'm aware I'll need to use Mongo instead, but having an integrated front and back seems to be sensible and have some advantages. So my question is what are the advantages of having a separate REST

Listen EADDRINUSE error while debugging in sails

两盒软妹~` 提交于 2019-12-19 03:44:23
问题 I am trying to debug my code using node-inspector but I am getting this error in my Terminal window again and again $ sudo sails debug info: Running app in debug mode... info: You probably want to install / run node-inspector to help with debugging! info: https://github.com/node-inspector/node-inspector info: ( to exit, type <CTRL>+<C> ) Error: listen EADDRINUSE at exports._errnoException (util.js:746:11) at Agent.Server._listen2 (net.js:1156:14) at listen (net.js:1182:10) at Agent.Server

Sails.js + socket.io: Sending messages from server to clients

谁说我不能喝 提交于 2019-12-19 03:28:04
问题 I'm attempting to set up a system with sails.js to have the server broadcast messages to a set of clients. Basically: A client in Group A sends an AJAX request to the server. The server processes the request and sends a message through socket to all clients of Group B. The clients of Group B receive the message through the socket and display something. According to the socket.io documentation, I should be able to have the clients in Group B join a "room", and then have the server broadcast to

Passport authentication not working in sails.js application

℡╲_俬逩灬. 提交于 2019-12-18 21:26:33
问题 I have a Sails JS application. I am trying to setup authentication using Passport.js authentication layer sails-generate-auth. I have configured my app by following the steps given in their documentation. But when I lift my sails app, authentication is not working. I am able to access the controllers, even when I am not logged in (It's not redirecting to my login page). I added a console.log statement in api/policies/passport.js as follows: module.exports = function (req, res, next) {

Sails.js: How to actually run tests

泪湿孤枕 提交于 2019-12-18 16:51:43
问题 I'm completely new to sails, node and js in general so I might be missing something obvious. I'm using sails 0.10.5 and node 0.10.33. In the sails.js documentation there's a page about tests http://sailsjs.org/#/documentation/concepts/Testing, but it doesn't tell me how to actually run them. I've set up the directories according to that documentation, added a test called test/unit/controllers/RoomController.test.js and now I'd like it to run. There's no 'sails test' command or anything

Bcrypt: invalid ELF header with Docker and Sails.JS

蹲街弑〆低调 提交于 2019-12-18 15:55:05
问题 My Node Dockfile : # Set the base image to ubuntu FROM ubuntu # Define working directory ADD . /src WORKDIR /src # Install Node.js & other dependencies RUN apt-get update && \ apt-get -y install curl && \ apt-get -y install sudo && \ curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash - && \ apt-get -y install python build-essential nodejs RUN npm install -g node-gyp && \ node-gyp clean && \ npm cache clean RUN node -v # Install nodemon RUN npm install -g nodemon ADD package.json /src

Specify returned fields in Node.js / Waterline?

邮差的信 提交于 2019-12-18 15:54:20
问题 I want to make a request like: User.find().exec(function(){}); I know I can use toJSON in the model however I don't like this approach since sometimes I need different parameters. For instance if it's the logged in user I will return their email and other parameters. However if it the request fort he same data is made by a different user it would not include the email and a smaller subset of parameters. I've also tried using: User.find({}, {username:1}) ... User.find({}, {fields: {username:1}

Personalized chat using Sails.js

倖福魔咒の 提交于 2019-12-18 13:42:10
问题 Is there a way in sails.js or a tutorial that would help me build a peer to peer chat, using sockets, something like pubnub. I am trying to implement a personalized chat feature using sails.js What that would mean is that I have say multiple users in my application and a user can chat with another user. So if user A sends a message in user B chatbox, B(only) receives and vice-versa. I have gone through http://sailsjs.org/#!documentation/sockets , the documentation by it gives examples using

How to provide custom model validation message in Sails.js?

白昼怎懂夜的黑 提交于 2019-12-18 13:16:54
问题 How to provide custom model validation message in Sails.js? The validation messages returned by Sails.js is not user friendly so I wanted to provide a custom validation message for rules like required, minLength etc... but don't really know how. It's not in the docs and I also checked the docs of Anchor.js w/c is the validator used by Sails but its also not there. UPDATE: Haven't got a response last week so I implemented my own solution, wanted to share it since it might be useful for others

Sails.Js - How I do pagination in sails.Js

蓝咒 提交于 2019-12-18 11:45:49
问题 I want to create paginated table using sails.js, mongodb and waterline-ORM. Is there a any specific way to do pagination in sails.js? 回答1: http://sailsjs.org/#/documentation/concepts/ORM/Querylanguage.html Model.find().paginate({page: 2, limit: 10}); Model.find({ where: { name: 'foo' }, limit: 10, skip: 10 }); If you want the pagination to work asynchronously, its very easy to do with JQUERY $$.getJSON and on the server res.json(); Theres a lot of info in waterline and sails docs. 回答2: There