sails.js

Create subfolders in Sails.js /api/controllers

跟風遠走 提交于 2019-11-28 03:25:41
问题 here is my problem: I would like to create some subfolders inside /api/controllers in order to organize my source code. My problem there is that as soon as I create a new folder, blueprint api / routes / actions don't seem to work anymore. From all my tests if I change /api/controller/UserController.js to /api/controller/newpath/UserController.js I can't get the beauty of blueprint working anymore. Is there any way to do that? Thanks Emmanuel 回答1: You can set this up. Its a bit undocumented,

Stop the auto migration of the schema in the sails.js

一世执手 提交于 2019-11-28 03:20:25
问题 In sails.js, how can we stop the automigration of the schema into the database. Sometimes,it gives error due to the migration. Is there a way that we can make the migration run only when the application is deployed? 回答1: You can also try something like this: module.exports = { // migrate: 'alter', // adds and/or removes columns on changes to the schema // migrate: 'drop', // drops all your tables and then re-creates them. All data is deleted. // migrate: 'safe', doesn't do anything on sails

How to serve a static folder in sails.js?

限于喜欢 提交于 2019-11-28 03:17:56
问题 I want to serve a folder app , which is at the same level with assets folder, under the url /app . It's possible with AppController to serve file according the url, but I want to know whether it is possible to do this like the following with express? app.use(express.static(__dirname + '/public')); 回答1: You can use custom middleware for express in sails by adding it to your config/http.js: var express = require('express'); module.exports.express = { customMiddleware: function (app) { app.use

How do I connect bower components with sails.js?

倖福魔咒の 提交于 2019-11-28 03:15: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. user3429154 In Sails 0.10 the 'assets/linker' directory no longer exists, however I found a lead on simple

AngularJS + sails.js

我们两清 提交于 2019-11-28 02:47:45
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-jade-stylus-seed and on running "grunt server" a "dist" folder is created which contains the final

npm install not installing things at /usr/bin

时间秒杀一切 提交于 2019-11-28 01:44:48
问题 I am trying to install SailsJS with: $ sudo npm install -g sails It works, install everything at /home/brunoluiz/npm/lib/node_modules/sails with the following log: /home/brunoluiz/npm/bin/sails -> /home/brunoluiz/npm/lib/node_modules/sails/bin/sails.js sails@0.9.16 /home/brunoluiz/npm/lib/node_modules/sails ├── connect-flash@0.1.1 ├── pluralize@0.0.5 ├── inflection@1.2.5 ├── grunt-sails-linker@0.9.5 ├── grunt-contrib-clean@0.4.1 ├── node-uuid@1.4.0 ├── async@0.2.9 ├── grunt-contrib-concat@0.3

How to serve a bootstrap template in sails 0.9?

时光总嘲笑我的痴心妄想 提交于 2019-11-27 21:43:17
问题 I wanted to know how to serve a bootstrap template through newer sails version . Should I update the links of JS to something else . I tried moving js and images in asset folder but javascript didn't work . The sails documentation is very poor on this topic . Can anyone tell a easy way to integrate it . Thanks in advance 回答1: Sails 0.9.x has moved to use Grunt for handling assets. This allows you to do many different kinds of pre-compilation and asset handling. By default, automatic asset

How to handle async concurrent requests correctly?

荒凉一梦 提交于 2019-11-27 21:04:33
问题 Let's say I have some sort of game. I have a buyItem function like this: buyItem: function (req, res) { // query the users balance // deduct user balance // buy the item } If I spam that route until the user balance is deducted (the 2nd query) the user's balance is still positive. What I have tried: buyItem: function (req, res) { if(req.session.user.busy) return false; req.session.user.busy = true; // query the users balance // deduct user balance // buy the item } The problem is req.session

the hook orm taking too long to load

空扰寡人 提交于 2019-11-27 20:31:57
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.js:110:15 when i rerun sails without changes it gives no error then.how can i avoid this error everytime

Using Waterline model outside SailsJS api

倖福魔咒の 提交于 2019-11-27 17:43:50
问题 Is it possible to use models defined within [app-name]/api/models outside api folder? I have created separate folder in application root, where I placed cron job that should fill my database every hour. I would like to reuse Models defined inside my api folder, but not sure how to do it. I see that I can do sails.lift inside that cron script but that doesn't seem very nice to me. Did someone experience something similar? I'm new to node.js, so maybe I'm missing something pretty obvious. 回答1: