sails.js

Emitting a message in sails v0.11 (client-side)

自作多情 提交于 2019-11-27 07:00:50
问题 I'm having some issues with the newest version of sails.js (0.11.0). It stated in github that plain socket.io code will be accepted and ran in sails.js; however, I am simply trying to emit a message from a client when they click on something like so: $('#myBtn').on('click', function(){ io.socket.emit('message', { message: { subject: subject }, sender: id }); }); I end up getting an "Uncaught TypeError: undefined is not a function" on the line of io.socket.emit() aka emit is not a function of

Auto reloading a Sails.js app on code changes?

大兔子大兔子 提交于 2019-11-27 06:09:29
Currently is seems that for any code change in a sails.js app you have to manually stop the sails server and run sails lift again before you can see the changes. I was wondering if there is any way when running in development mode to automatically restart the sails server when it detects a code change? Sandro Munda You have to use a watcher like forever , nodemon , or something else... Example Install forever by running: sudo npm install -g forever Run it: forever -w start app.js To avoid infinite restart because Sails writes into .tmp folder, you can create a .foreverignore file into your

How do I connect bower components with sails.js?

荒凉一梦 提交于 2019-11-27 05:05:38
问题 I'd like to be able to install Javascript dependencies through bower and use them in a sails.js app, but I can't figure out a way to do this with out just copying an pasting files from the bower_components folder to the Sails assets folder. Ideally I think I'd like to use requirejs and point to the bower components in the main.js file. I may be trying to pound a square peg in a round hole, please let me know if so. Any thoughts on managing components/libraries with Sails are welcome. 回答1: In

AngularJS + sails.js

最后都变了- 提交于 2019-11-27 04:58:29
问题 I am developing an app that can utilize sails.js for back-end and AngularJS for Front-end. I thought that I'll create an Angular App using Yeoman-angular generator https://github.com/yeoman/generator-angular, and once I am done with the front-end logic I'll create a sails app using, npm install -g sails sails new app And then I'll transfer all my AngularJS files to the Sails folder. But the thing is that AngularJS creates creates a folder hierarchy like this https://github.com/rishy/angular

the hook orm taking too long to load

白昼怎懂夜的黑 提交于 2019-11-27 04:28:53
问题 i am using two database adapters with sails. one for mondoDB and second for mysql.whenever i run command "sails lift".once it gives an error error: Error: The hook `orm` is taking too long to load. Make sure it is triggering its `initialize()` callback, or else set `sails.config.orm._hookTimeout to a higher value (currently 20000) at tooLong [as _onTimeout] (C:\Users\KAMI\AppData\Roaming\npm\node_modules\sails\lib\app\private\loadHooks.js:92:21) at Timer.listOnTimeout [as ontimeout] (timers

Sails.js + Passport.js authentication through websockets

最后都变了- 提交于 2019-11-27 00:44:49
问题 When I use Sails.js with Passport.js, the isAuthenticated method does not exist on the req object when requested through websocket. Could anyone tell me why this happens? 回答1: Alternatively, you can hijack the 'router:request' event to plug in passport for socket requests. I do this in 'config/bootstrap.js': module.exports.bootstrap = function (cb) { var passport = require('passport'), initialize = passport.initialize(), session = passport.session(), http = require('http'), methods = ['login'

How to create global variables accessible in all views using Express / Node.JS?

走远了吗. 提交于 2019-11-26 23:35:46
Ok, so I have built a blog using Jekyll and you can define variables in a file _config.yml which are accessible in all of the templates/layouts. I am currently using Node.JS / Express with EJS templates and ejs-locals (for partials/layouts. I am looking to do something similar to the global variables like site.title that are found in _config.yml if anyone is familiar with Jekyll. I have variables like the site's title, (rather than page title), author/company name, which stay the same on all of my pages. Here is an example of what I am currently doing.: exports.index = function(req, res){ res

sails.js - I want to add DB connection dynamically after sails lift

梦想与她 提交于 2019-11-26 23:18:10
问题 During sails lift I don't yet have all the connection information for my DB. Is there a way to either have config values dependent on promises or dynamically create a connection after sails lift has completed? I would obviously have to add a policy or hook to handle requests to routes needing the model if it wasn't available yet, but at this point I don't see how to even let the sails lift until I already know the connection info (it must be in the configs). I'm hoping I'm missing a way to

sails.js Use session param in model

北慕城南 提交于 2019-11-26 18:34:24
问题 This is an extension of this question. In my models, every one requires a companyId to be set on creation and every one requires models to be filtered by the same session held companyid. With sails.js, I have read and understand that session is not available in the model unless I inject it using the controller, however this would require me to code all my controller/actions with something very, very repetitive. Unfortunate. I like sails.js and want to make the switch, but can anyone describe

Adding custom Express middleware like jQuery-File-Upload to Sails.js

坚强是说给别人听的谎言 提交于 2019-11-26 16:55:52
问题 I'm still having difficulty understanding how to add middleware to sails.js. I've heard use policies.js, create custom policies, add to local.js, etc. So could someone please show me how exactly I would add the jquery-file-upload-middleware to a sails app. Thanks in advance 回答1: This would have been very difficult in previous versions of Sails, because you had no control over the order in which custom middleware was included. In v0.10, it's just kinda difficult. Note: the following will work