sails.js

Javascript/Sails.js Controller waiting for service to call async function

痞子三分冷 提交于 2019-12-12 04:51:29
问题 It is very straightforward to use an asnyc call to wait for a Javascript function to complete, however it appears to be less clear how one should handle a Controller calling a Service which in turn calls an async function. Let's assume that I have a simple asynchronous method: foo.fooMethod( {format: _format, stuff: _stuff }, function( error, response, body ) { if ( error ) { sails.log( error ); res.send( "Error " + error, 500 ); } res.send( body, 200 ); }); In this scenario my async call

Sails EJS-view after html-pdf usage does not render image

◇◆丶佛笑我妖孽 提交于 2019-12-12 04:28:25
问题 I need to be able to render html views (nothing new there) and to provide the same views as PDF file to the final user. The first case works perfectly on my side : I managed to render a simple html5 document aswell as an image two times (the base64 version + the standard way). Unfortunately, when I try to convert it to a PDF file thanks to html5-to-pdf or html-pdf , the non-base64 version of the <img> tag does not work and is signaled as a missing resource within the PDF File. The code I'm

Can't get the 'sails-generate-new-with-mast' generator to work in sails 0.10

旧巷老猫 提交于 2019-12-12 04:12:34
问题 working with sails beta v0.10-rc8 installed globally. i'm using mac osx 10.9. sudo npm install sails@beta -g Then I installed the generator npm package both globally (just to give it a shot) and locally in the folder that will contain the project to be generated like: ~/projects& npm install sails-generate-new-with-mast created the .sailsrc file in the folder containing the project ~/projects/.sailsrc and in ~/.sailsrc the file content is: { generators: { modules: { new: 'sails-generate-new

Why res.json() not working?

和自甴很熟 提交于 2019-12-12 03:29:26
问题 I'm new to sails.js and I'm trying to learn how to use models and controllers together. For that I have created the code given below. Now when I visit ....../corporate_info I see all the required fields in JSON format in PostMan. But it doesn't seem to be 'coming from' the res.json({}) I have defined in corporate_info.find() because the response doesn't have a property "data" in it. It should be actually {data : mydata} ? blueprints.js rest: false Corporate_infoController module.exports = {

Integrate cross-domain-socket.io using sails.io library to client

故事扮演 提交于 2019-12-12 03:23:47
问题 I have written a chat application based on sails.js on my server so basiclly all the code in the client side was running on the localhost. the chat is working like a dream but now i want to move all the client side to my cordova application. this is my server side code(socket.js) onConnect: function(session, socket) { // By default, do nothing. console.log('hello'); socket.emit('news', "Welcome to the chat"); socket.on('send message', function(data){ console.log(data); socket.broadcast.emit(

What is the production-readiness of sails.js and meteor.js, and how to they compare to Django? [closed]

我们两清 提交于 2019-12-12 03:14:18
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 4 years ago . I am thinking of using either one of them in building our startup which is like a job portal with validation,verification and includes special features for freelancing and all. Is meteor or sails good for using as a backend or should we go with more robust backend like Django

sailsjs policy causing Can't set headers after they are sent error

本小妞迷上赌 提交于 2019-12-12 03:09:39
问题 I have this policy that basically checks a users access to an object before allowing them to do anything with it. So, does user 1 have access to event 4 in order to /event/edit/4 kind of thing. I tried creating a policy (I've edited the top part, so if there are errors in this, trust me that it runs the return res.direct when it's supposed to) but when it hit's the right condition the sails process dies with an error of "Can't set headers after they are sent." I took out another policy that

How to return two Objects in a Promise using Sails?

[亡魂溺海] 提交于 2019-12-12 02:59:31
问题 I'm using SailsJs v0.11.3 and I want to use Promises to avoid using nested callback but I don't know how to return two objects from one stage ( .then() ) to another one. My code looks like this but I got undefined when trying to print start param on the third .then statement. User.findOneById(userId) .then(function (result) { // #1 return result; }).then( function (result_a) { // #2 console.log('---------------- ' + result_a ); var result_b = User.findOneById(ownerId) .then(function (result)

Image uploading Android + Sails.js

那年仲夏 提交于 2019-12-12 02:39:15
问题 What are the possible ways/libraries available to upload images from android app to sails.js Node.js server? One way that I came across to achieve this is sending Base64 encoded Bitmap image string from the app and saving it to the database, but this seems to be an inefficient way to handle multiple big size images as Base64 encoded string is 33% larger than raw size. Another way is to send images as multipart form data, but I couldn't found good examples on this. Please, provide examples

how can I limit specify filed in rest api result in sailjs

只谈情不闲聊 提交于 2019-12-12 02:38:47
问题 I'm using restapi in sailsjs , I have a user model: module.exports = { schema: true, attributes: { username : { type: 'string' }, real_name : { type: 'string' }, encrypted_password: { type: 'string' }, id_card : { type: 'string' }, is_verify : { type : 'boolean' } , email : { type: 'string' }, phone : { type: 'string' } }, }; I would like to expose some rest api , but I only allow findOne method , and what's more : I DON'T want the result contains id_card , because it's kind of private info.