sails.js

Backbone view in sails .ejs file

寵の児 提交于 2019-12-08 10:24:54
问题 I am trying to access backbone views in sails framework. I fetch data from the server and I am trying to push them to the DOM. Actually, I ve created a model-controller for the tags I store data from mongo to tags model and I return to backbone the url of tags view. I want to display those data to my DOM element. I am trying to find how is it possible to do so in the sails since I am receiving is not defined error. My DOM element code is the following: 51| <div id="profiles" class =

SailsJS user access levels and roles

≯℡__Kan透↙ 提交于 2019-12-08 09:40:17
问题 I am using what I have learnt here to build a user authentication system. Essentially it is using passport local auth. How would I add users access levels and roles to SailsJS? For example I would like access levels (canWriteAll, canWriteOwn, canRead) with user roles that these are assigned to (admin, contributor, user...etc..). 回答1: Sails has built-in policy based access control system. Check out documentation first. The simple form if it is: create required access level attribute in your

npm not install underscore packages

こ雲淡風輕ζ 提交于 2019-12-08 08:12:24
问题 I want to install packages with npm : my packages file is: "dependencies": { "express": "~3.3.6", "socket.io": "0.9.16", "jade": "~0.35.0", "less-middleware": "~0.1.12", "redis": "~0.8.4", "connect-redis": "~1.4.5", "longjohn": "~0.2.1", "mongoose": "~3.6.20", "json-stringify-safe": "~5.0.0" }, "devDependencies": { "grunt": "~0.4.1", "grunt-contrib-uglify": "~0.2.2", "grunt-nodemon": "~0.1.0", "grunt-contrib-jshint": "~0.6.3", "grunt-contrib-less": "~0.7.0", "grunt-ngmin": "0.0.3" } } but i

Sails js route static html

…衆ロ難τιáo~ 提交于 2019-12-08 07:17:05
问题 I want to completely separate the client and server sides in my sails js app. If I remove the '/' route, automatically it will serve a file named index.html from the 'assets' folder. I want to serve another file from the assets folder, how can I do it? 回答1: If you look at the middlewares that sails uses config/http.js order: [ 'startRequestTimer', 'cookieParser', 'session', 'myRequestLogger', 'bodyParser', 'handleBodyParserError', 'compress', 'methodOverride', 'poweredBy', '$custom', 'router'

Command Validation in Minimist

独自空忆成欢 提交于 2019-12-08 05:55:32
问题 Newbie to Minimist command parser and facing an issue with it. User enters a command : Project -a I have to validate if entered command has right option. So my code is as follows: var commands = ["project", "user"]; var commandEntered = require('minimist')(command.split(' ')); if(commands.indexOf(commandEntered._) > -1){ //i.e. Check if user has entered either project or user and then do following if(commandEntered._ == "project") { var options = ["a", "u", "l"]; delete commandEntered._; var

Connect from a client to a sails based server

痴心易碎 提交于 2019-12-08 04:15:59
问题 I am trying to connect to my sails based server from my cordova client using the library sails.io. this is my client code: <!-- cordova script (this will be a 404 during development) --> <script src="lib/ngCordova/dist/ng-cordova.js"></script> <script src="cordova.js"></script> <script src="lib/angular-socket-io/socket.js"></script> <script src="lib/angular-sails/src/ngSails.js"></script> <script src="lib\socket.io-client\socket.io.js"></script> <script src="lib/sails.io.js/sails.io.js"><

Waterline (Sails.js): AND conditions

百般思念 提交于 2019-12-08 04:14:17
问题 I'm using mongodb with sails.js querying a model that contains the titles of torrent files. But I'm not able to perform a waterline query using the "AND" condition. I've already tried it in several ways but most of them return empty or simply, never return. e.g. the database contains an entry with: "title": "300 Rise Of An Empire 2014 720p BluRay x264-BLOW [Subs Spanish Latino] mkv" When adding each query parameter line by line: var query = Hash.find(); query = query.where({ "title": {

whitespaces when adding partial template using EJS

ⅰ亾dé卋堺 提交于 2019-12-08 04:04:12
问题 I am using SailsJS with EJS engine. When I add partials using <% include partials/template.ejs %> or <% partial('partials/template.ejs') in the layout file, I get whitespaces before the compiled HTML code (template.ejs). Note that when I copy paste the template.ejs content in the layout (not using include/partials) the whitespaces are gone. See images below: 1st part: code. 2nd part: chrome DOM. 3rd part: whitespace element inspection (DOM properties) 回答1: I have faced the same problem. What

passport local type error

谁说胖子不能爱 提交于 2019-12-08 03:22:35
问题 I'm trying to use passport-local for authentication in my Sails project. In my controller: passport.authenticate('local', function(err, user, info) { if ((err) || (!user)) { res.json({message: 'Unable to authenticate'}); return; } req.login(user, function(err) { if (err) { res.json({message: 'Unable to login'}); console.log(err); return; } res.json({message: 'logging in'}); }); })(req, res); In a config file: passport.use(new LocalStrategy(function(username, password, done) { User

Using Node cluster module with SailsJs: EADDRINUSE

拟墨画扇 提交于 2019-12-08 02:43:16
问题 I have a SailsJs (http://sailsjs.org/) based application that has to deal with some CPU intensive tasks. In short, I want to use the cluster (https://nodejs.org/api/cluster.html) module to delegate the processing of these tasks to worker processes so that the main event loop of the Sails application isn't blocked (and so can respond to requests as normal). When creating a worker, I'm getting an EADDRINUSE error as Sails is trying to run again and bind to the same port. Sample code: //