sails.js

Where to access and store EJS Helpers - SailsJS

て烟熏妆下的殇ゞ 提交于 2019-12-01 04:13:35
问题 Well, SailJS's default templateing engine is EJS ( Embedded Javascript ) But I cannot seem to find the place where we can create our own helpers and stuff. So, do you know where to access & store EJS helpers/stuff? 回答1: solved: https://github.com/balderdashy/sails/issues/2162#issuecomment-55866731 config/http.js module.exports.http = { // ... locals: { filters: { formatDate: function(date) { } } } } config/bootstrap.js _.extend(sails.hooks.http.app.locals, sails.config.http.locals); At some

How to add production mode to sailsjs app when started using PM2

青春壹個敷衍的年華 提交于 2019-12-01 04:03:23
问题 To start sailsjs in production mode you append --prod . Run: node app.js --prod I'm using PM2 and a simple json file for settings, which contains name of process and scriptname, to kick off the node process. How would I pass the production argument using PM2? 回答1: Read PM2 JSON app declaration. E.g. (not tested) [{ "name" : "Sails", "script" : "./app.js", "args" : "['--prod']" }] 回答2: first delete: pm2 delete app again: pm2 start app.js -x -- --prod 回答3: You can also use something like this:

Deploy Sails.js on Openshift … app restarting over and over [duplicate]

笑着哭i 提交于 2019-12-01 03:48:27
This question already has an answer here: Deploying Sails.js On Openshift 1 answer I want to deploy sails.js (version 0.9.7) app to Openshift but after git push I get this log: debug: Lowering sails... DEBUG: Starting child process with 'node app.js' . . . info: Server lifted in `/var/lib/openshift/525ccaba5973caa65100002b/app-root/runtime/repo` info: To see your app, visit http://127.7.215.1:8080 info: To shut down Sails, press <CTRL> + C at any time. . . debug: -------------------------------------------------------- debug: :: Tue Oct 15 2013 03:03:56 GMT-0400 (EDT) debug: debug: Environment

How to use custom route middleware with Sails.js? (ExpressJS)

孤人 提交于 2019-12-01 03:25:21
I've just unpacked a fresh copy of the Node framework Sails.js. It is built on Express 3. In the /config/routes.js file is this comment: /** * (1) Core middleware * * Middleware included with `app.use` is run first, before the router */ /** * (2) Static routes * * This object routes static URLs to handler functions-- * In most cases, these functions are actions inside of your controllers. * For convenience, you can also connect routes directly to views or external URLs. * */ module.exports.routes = { ... In the same config folder I have created the file called is_ajax.js. // Only run through

sails.js + waterline One-To-Many model association, what should happen when deleting the Many?

社会主义新天地 提交于 2019-12-01 02:41:29
问题 I have a one to many relation between Teacher(One) and Children(Many). If I do: Teacher.destroy(teacherId).exec(function(err){}); The children are not automatically removed. Is it a bug or should I delete them manually? If that's not a bug, what is the explanation for not deleting children? 回答1: Waterline currently doesn't support cascading deletes. It may be a configuration option in future versions, but it will probably never be the default. In most production-ready apps you probably should

Sending Socket request from Client (iOS & Android) to Sails.js Server

牧云@^-^@ 提交于 2019-12-01 01:26:29
I'm trying to use socket.io with iOS and Android App, but there is some problem here. I'm asking if there is anyone who actually has solutions. How can I send socket.io request from client (iOS, Android), I think there is socket.io libraries for iOS and Android and iOS lib has sendEvent/Message/JSON methods. However, I couldn't find a way to get the events at the sails. https://github.com/pkyeck/socket.IO-objc https://github.com/koush/AndroidAsync So is there any way that I can send socket.io event from client? So I can use it like join: function (req, res) { sails.sockets.join(req.socket, req

Sails.js rolling sessions

不羁的心 提交于 2019-12-01 00:19:44
A rolling session is a session that expires in a set amount of time should there be no user activity(excluding websockets live updating data). If the user visits another part of the site before expiry, the expiry should then be extended. How would I do this with Sails.js? Setting maxAge and expires under cookie in /config/session.js does not have the desired effect. The expiry does not get extended with another page load. It stays constant. EDIT: Will this be resolved once Sails.js upgrades its Express version? I see https://github.com/expressjs/session has a rolling option. EDIT2: I see this

How to use custom route middleware with Sails.js? (ExpressJS)

巧了我就是萌 提交于 2019-12-01 00:11:07
问题 I've just unpacked a fresh copy of the Node framework Sails.js. It is built on Express 3. In the /config/routes.js file is this comment: /** * (1) Core middleware * * Middleware included with `app.use` is run first, before the router */ /** * (2) Static routes * * This object routes static URLs to handler functions-- * In most cases, these functions are actions inside of your controllers. * For convenience, you can also connect routes directly to views or external URLs. * */ module.exports

One to many associations using existing join table

心不动则不痛 提交于 2019-11-30 22:49:51
I'm converting the backend of an existing application that uses MariaDB to use Sails (v0.10.0-rc7) and I'm stuck trying to figure out how to get all permissions for a role populated into the Role model given the underlying schema structure I have to work with. There are three tables that are used to currently get a role and it's associated permissions, and the working query looks something like this: SELECT pm.permission, pm.permkey FROM role_master rm INNER JOIN role_perm rp ON ( rm.roleid = rp.roleid ) INNER JOIN perm_master pm ON ( rp.permid = pm.permid ) WHERE rm.roleid = 1 GROUP By pm

Sails workaround for deep populate

时间秒杀一切 提交于 2019-11-30 22:35:31
I'm trying to deep populate a collection. For example // UnitType.js name: { type: 'string' } // Unit.js unitType: { model: 'unitType', via: '_id', required: true, index: true } // Product.js unit: { model: 'unit', via: '_id', required: true, index: true }, The problem is, that - as far I know from internet research deep populate like Product.find().populate('unit.unitType'); is currently not supported in sails. To achieve the result I want I currently query Products with populate unit query UnitTypes with the id from `product.unit.unitType`` .map() product.unit.unitType with the response This