sails.js

How can I set different <title> values for each template in ejs?

瘦欲@ 提交于 2019-12-06 08:36:58
问题 I am using Sails.js and it comes with ejs-templates. There is a default view called layout.ejs which is always including the body parts from other templates. The title element is defined in the layout.ejs and is therefore always the same. Due to SEO I would like to change the title depending on the view that is included. Is there some way of knowing which view is actually called from Sails, in the .ejs file? 回答1: Update the <title> tag of your layout.ejs to <title><%= title %></title> and

Sails.js: How to know if the request contains a file to upload?

我是研究僧i 提交于 2019-12-06 05:59:25
问题 I have the next action in one of my controllers, its function is upload a image file or create a new cover model using a video url, its work fine but when the request has a header Content-Type: multipart/form-data and does not contains a file the action throw a timeout error in req.file() . upload: function(req, res) { res.setTimeout(0); function onCreateCover(err, cover) { if (err) { return res.negotiate(err); } else { res.status(201); return res.json(cover); } } if (/^multipart\/form-data/

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

会有一股神秘感。 提交于 2019-12-06 05:56:32
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. 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 - styles and scripts - inside /assets , take a look bellow for more information. Disable that behavior on config

How to connect Socket.IO-Client to Sails.js server?

こ雲淡風輕ζ 提交于 2019-12-06 05:55:17
I've spent quite a while trying to connect Socket.IO-Client to a server running on Sails.js framework. The client is basically a simple JavaScript application running with Node.js on Raspberry Pi. The idea is that a simple device connects to a server, the server then registers the device and subscribes it for messages. The device receives a message from the server and performs some actions. I don't want the client to be dependant on any framework and, for that reason, I am trying to avoid using Sailsjs-socket.io-client. At the moment both server and the client are running on my local machine.

sails.js nested models

限于喜欢 提交于 2019-12-06 05:19:17
问题 In sails.js 0.10 I'm trying to do the following // user.js module.exports = { attributes: { uuid: { type: 'string', primaryKey: true, required: true } , profile: { firstname: 'string', lastname: 'string', birthdate: 'date', required: true } } }; I'm getting an error when trying to create a user and sailsJS doesn't recognize the "profile" attribute. I'm not sure if sails supports the nested JSON structure, and if it does I'm not sure how to structure it. error: Sent 500 ("Server Error")

Sails js 9.4 - assets not being copied

谁说我不能喝 提交于 2019-12-06 04:56:34
问题 First sails didn't create .tmp/public, so i did it manually. But it also doesn't copy stuff from my assets folder to my public folder. Can someone explain why that is? # At that time, the answers i got weren't helping, I've updated to 9.8 now, and i don't seem to have any problem. # 回答1: I had this same issue. When running sails lift the .tmp folder wasn't created. What finally worked for me was installing Grunt locally in the root folder of my sails app. So just run npm install grunt in your

Playing mp3 on website created with Node.js

断了今生、忘了曾经 提交于 2019-12-06 04:40:49
问题 I've searched for hours and several days for a good solution for my problem. First of all my scenario: I am building a website with Node.js - especially Sails.js. The goal is to have a list of mp3 files of my server side directory (that's already done) that are litet as links on the client side (website). When I click on one link I want the file to be loaded in my HTML Audio Tag (or if theres a better node.js specific solution with start/stop controlling it would be fine too). And that's the

How to import and use a regular vuejs component in sailsjs?

馋奶兔 提交于 2019-12-06 04:36:40
I need to use a vue component packages as npm module with sails. Tried everything: can't import it into the page instance, import not allowed there; can't import it into a parasails.registerCompnent, same error; require also not working; importing it in the main app.js doesn't serve. Looked everywhere, it is terribly frustrating, no information anywhere. It is one of the moments I regret choosing sails for my project. Anyone having a working example of how to use a npm pachages vue component in a sails instance page? From what I can tell, you can't import in the component as a package. What

How to extract distinct values from a mongo database using Waterline and Sails.js (version 0.10)?

好久不见. 提交于 2019-12-06 04:25:50
Using Sails.js version 0.10.x , assume I have a model Dog , populated as follows (writtenout in yaml format for convenience, but in my case it's actually in a mongo database.) dogs: - breed: "wolf" name: "Fido" - breed: "wolf" name: "Roger" - breed: "dingo" name: "Nipper" - breed: "dingo" name: "Ernie" - breed: "corgi" name: "Bernadi" - breed: "corgi" name: "Queenie" - breed: "poodle" name: "Christopher" - breed: "poodle" name: "Tony" etc So now I want to create a list of the available breeds. Dog.find().exec(err, dogs) { breeds = []; dogs.each(function(dog)) { if (breeds.indexOf(dog.breed) ==

How to access request object in sails.js lifecycle callbacks?

让人想犯罪 __ 提交于 2019-12-06 02:47:31
问题 Suppose I have this model: module.exports = { attributes: { title: { type: 'string', required: true }, content: { type: 'string', required: true }, createdBy: { type: 'string', required: true } } } I need to set the current user id to the model's createdBy attribute. I thought I could do that with the beforeValidate lifecycle callback, but I can't access the request object where the current user is stored. Is there a way to access it, or should I solve this somehow else? I tried this with no