sails.js

sails logging to file

自闭症网瘾萝莉.ら 提交于 2019-12-18 11:07:12
问题 Can someone provide an example of how to configure sails.js to log to a file? It seems like it should be straightforward, but I'm having trouble finding examples online. I'm looking at changes in the config/log.js or the config/sockets.js files. 回答1: According to the source code, for v0.9.x , you just have to set the filePath in your config/log.js : module.exports = { log: { level: 'info', filePath: 'application.log' } }; 回答2: Logging to a file doesn't work out of the box. You need to invoke

How to configure partials and layouts for Handlebars in Sails.js?

自作多情 提交于 2019-12-18 10:56:10
问题 I run Sails 0.9.7 and have installed Handlebars which is supported by Consolidate.js and therefore is supported by Sails I can serve pages from .handlebars files, it works just fine. I can't figure where, in Sails workflow, and in a Sails way , I should register partials, helpers etc... I'm more looking for best practices than just a working solution but any help will be appreciated. 回答1: I'm running v0.10 beta but this shouldn't affect how I got it working below: Engine should be handlebars

How to render a view to a string?

大兔子大兔子 提交于 2019-12-18 09:25:25
问题 I want to render a specific view in a sailsjs controller/action which should be sent out as email. I have the following sample action: function registerAction(req, res) { // handle user registration // email user sendEmail({ to: newUser.email, subject: "Welcome", text: /* VIEW RENDER HERE */ }); // render view to the user return res.view({ user: newUser }); } How can I render a view-template with the tools sailsjs provides so that I don't need to hardcode an email text or use other libraries?

How to make JQuery file upload plugin call backend only once for all the files in an upload?

耗尽温柔 提交于 2019-12-18 09:10:10
问题 I'm using sails.js to build a website. I have a model named timeline . It has some text fields along with a collection named pictures . Each timeline can have multiple pictures . I want to update all these fields at once when user clicks save . I'm using JQuery file uploader to help multifile upload. Problem is, JQuery file upload calls my backend file-uploader service once for each picture uploaded. I need to update the other text fields only once and they need to be updated before the

sails.js v0.10 create new project --linker not working Gruntfile.js not used

。_饼干妹妹 提交于 2019-12-18 09:04:22
问题 With the default version of sails on npm (v.9?) --linker works ok i.e. creates /linker folder. I can copy js, css files to assets/linker/ and they appear in layout.ejs automatically. I now have sails v0.10 installed both locally and globally. Using Node V0.10.25. I created a new sails project using: sails new project_name --linker but no /linker folder is created. I had to create /.tmp as it did not exist I had to create /.tmp/public/linker/ to put /js & /styles and add them manually into

Sails.js checking stuff before uploading files to MongoDB with skipper (valid files, image resizing etc)

▼魔方 西西 提交于 2019-12-18 04:23:13
问题 I'm currently creating a file upload system in my application. My backend is Sails.js (10.4), which serves as an API for my separate front-end (Angular). I've chosen to store the files I'm uploading to my MongoDB instance, and using sails' build in file upload module Skipper. I'm using the adapter skipper-gridfs (https://github.com/willhuang85/skipper-gridfs) to upload the files to mongo. Now, it's not a problem to upload the files themselves: I'm using dropzone.js on my client, which sends

Sailsjs change localization

北城余情 提交于 2019-12-18 02:49:51
问题 I've been using Sails.js for quite some time and was wondering if there is a way to manually change the localization from the controllers depending on the url. Example: http://example.com/en will return the English version and http://example.com/de will return the German one. Thanks for your help!! 回答1: You can always change the locale in a controller action by using req.setLocale() or by setting the value of req.locale . You can also handle this more globally by using a policy: // config

Skipper in SailsJS (beta) image resize before upload

瘦欲@ 提交于 2019-12-17 20:34:56
问题 I'm using SailsJS (beta). I'm trying to find a way to use graphicsmagick to take the stream parsed by Skipper in SailsJS-beta to resize the image before calling the Skipper-function req.file('inputName').upload() . My goal is to take my large, original image, and resize it before uploading it. Sails beta have introduced the Skipper-file-parser which are poorly documented (at least I don't understand it). Please help me understand how to resize the image before upload. This works (code in my

Correct way of handling promisses and server response

 ̄綄美尐妖づ 提交于 2019-12-17 20:31:04
问题 I am trying to improve my code in node.js / sail.js and I am fighting server response in promisses. When you look at the first .then function you can see that method returns false in case of forbidden access or notFound . Then, in the next .then functions I must check if the return type is === false to skip to section and avoid sending http headers twice. Can this be improved somehow, to skip all next .then methods in case of failure? I can throw an Exception to go in the last .catch but then

Upload multiple files in angular

与世无争的帅哥 提交于 2019-12-17 18:15:06
问题 I've a situation where I've a form in which I've a row where I've two text fields entries and I've to upload a file for that row and this kind of rows can be 'N' and then there is a master files that can be entered for whole form while these are some part of the form and I've to submit all these files at once on clicking a save button. I'm kind of stuck with ng-upload it needs an api call, and I really can't have more than one api call for this form. The sample html code is below : <!DOCTYPE