sails.js

How to upload a file using the new controller actions format in sails.js

别来无恙 提交于 2019-12-23 05:12:29
问题 Someone know how I could upload a file to a controller action using the (inputs, exists) format of sails.js, this is my try: module.exports = { friendlyName: 'Upload file recording', description: 'Upload a recording to AWS', inputs: { name: { required: true, type: 'string' }, mimeType: { required: true, type: 'string' }, recording: { type: 'ref' } }, exits: { noRecordings: { responseType: 'no recordings', description: `You don't have any recording for this event`, }, serverError: {

Sails.js background processing loop, not related to connections

余生颓废 提交于 2019-12-23 03:51:30
问题 If you have a process loop you want to run continuously after delays with setTimeout (regardless of connections) where would that code go and be executed from? It looks like the code would go in the services directory, but where do I start the loop? I tried in the app.js, but that doesn't work once sails is lifted it doesn't look like Simple Example // MyFoo.js module.exports = { shouldFoo: true, doFoo: function(){ if(this.shouldFoo){ console.log('fooing ...'); setTimeout(foo, 1000); } else {

the best way to exclude some data from a method in sails controller

試著忘記壹切 提交于 2019-12-23 02:01:58
问题 I want's to exclude some data in some controller method and in other method i want's that data. I do it with forEach function right into method after finding that : nine: function (req, res) { Dore.find() .limit(9) .sort('createdAt DESC') .populate('file') .exec(function (err, sh) { if (err) { return res.negotiate(err); } else { console.log('before : ', sh); sh.forEach(function (item, i) { delete item.zaman; }); console.log('after : ', sh); return res.send(sh); } }); }, I want to know how

Sailsjs - Custom Logging with Winston

爷,独闯天下 提交于 2019-12-23 01:04:40
问题 I am currently trying to write a custom logger for sailsjs that will use winston to send files to either an s3 bucket or a mongodb database. The documentation seems to be lacking but so far i have found this: var customLogger = new winston.Logger({ transports: [ new(winston.transports.File)({ level: 'debug', filename: './logs/my_log_file.log' }) ] }); module.exports.log = { colors: false, // To get clean logs without prefixes or color codings custom: customLogger }; Which overall is not

Service that returns data from an asynchronous method

喜夏-厌秋 提交于 2019-12-22 18:36:16
问题 I am using Sails' ORM (Waterline). I have written a geturl service that should return the url of several models/actions in my app. I am currently calling this service inside my templates. (As I am alone to develop this, don't hesitate to warn me if this design pattern is wrong) Now it occurs that Waterline's .find() method is asynchronous (as it should). I always use callbacks to do things when inserting or fetching things in database. Now I have seen everywhere that I cannot return any data

sails.js: how to disable etags

廉价感情. 提交于 2019-12-22 17:42:23
问题 I read this not very new post about disabling some things in sails.js. Specifically what I would like to try out is the disabling of etags. Does anyone know how to disable that in sails.js (0.11.0)? 回答1: You could disable it in the bootstap.js file: // config/bootstrap.js module.exports.bootstrap = function(cb) { // Add this line to access to the Express app and disable etags sails.hooks.http.app.disable('etag'); // It's very important to trigger this callback method when you are finished //

sails.js: how to disable etags

情到浓时终转凉″ 提交于 2019-12-22 17:42:13
问题 I read this not very new post about disabling some things in sails.js. Specifically what I would like to try out is the disabling of etags. Does anyone know how to disable that in sails.js (0.11.0)? 回答1: You could disable it in the bootstap.js file: // config/bootstrap.js module.exports.bootstrap = function(cb) { // Add this line to access to the Express app and disable etags sails.hooks.http.app.disable('etag'); // It's very important to trigger this callback method when you are finished //

String of certain length in Sailsjs Model

放肆的年华 提交于 2019-12-22 14:55:17
问题 How can I enforce a Model property to be exactly 32 characters long? I have tried key : { type: 'string', len : 32 } but it doesn't work. 回答1: Ok, let me tell you what i did. After reading hours y figure out that "columnType" property is the solution. It works together with "type" property. For example. I have a "description" field. It looks like: descripcion: { type: 'string', columnType: 'varchar (27)' } And it works. (this is for mysql db). I hope this works for you. This is on the docs.

How to make a app using sails js + a vue js template?

耗尽温柔 提交于 2019-12-22 12:25:12
问题 First, i came from a PHP + CSS background, where i used to simply put the CSS files on header and JS on footer -- you know, classic stuff. Now, I`m trying to make a system using Sails JS as backend and a Vue JS template as frontend. I have no idea how to make this guys "talk to each other". Please, I appreciate any help. My best. 回答1: Right on the point: Put the .js files in your assets/js folder and your .css in assets/css . By default Sails inject in your layout.ejs all source files -

Can certain URLs be exempt from CSRF in sails.js?

戏子无情 提交于 2019-12-22 11:17:16
问题 I'm setting up Stripe to work with my sails.js server, and in order to use Stripe's webhooks, I need to disable CSRF for the URLs I provide to Stripe. Is it possible to make certain URLs exempt from CSRF POST requirements in sails.js? The only configuration I can find for CSRF is to turn it on globally, and looking through the source code for the csrf hook (https://github.com/balderdashy/sails/blob/master/lib/hooks/csrf/index.js) it looks like if I try to provide a custom object, it just gets