sails.js

socket connection always failing

喜欢而已 提交于 2019-12-24 14:32:01
问题 I'm writing an application that connects to a sails server. This application is written with cordova , angularJS and Ionic . When I launch my application in my browser (with ionic serve ) the socket fails to connect to the server. Here is the message I get: GET http://localhost:8100/socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_s…sails_io_sdk_language=javascript&EIO=3&transport=polling&t=1443472067762-4 404 (Not Found) The server is running locally on port 1337. I tried to change the

Sailsjs req.setLocale outside controller

假如想象 提交于 2019-12-24 14:31:32
问题 I want to set the locale to other language than the default one, in cronjob scheduler. https://github.com/ghaiklor/sails-hook-cron The cronjob scheduler code looks like that: // ['seconds', 'minutes', 'hours', 'dayOfMonth', 'month', 'dayOfWeek'] module.exports.cron = { job: { schedule: '0 0 12 * * *', onTick: function() { SomeService.sendSms() }, timezone: 'Asia/Jerusalem' } } But I cant set the locale because its not a controller but a service and I don't have access to req.setLocale

Node.js / Sails.js - Function in forEach loop

微笑、不失礼 提交于 2019-12-24 14:05:53
问题 I'm trying to get the following simplified code to finish and then move on synchronously: factors.forEach(function(factor, index){ Factor.findOrCreate({function_name: factor}).exec(function(){ sails.log('success'); }) }); How do I do it? So far I've tried: Putting lines 2-4 in a separate function and calling that from inside the loop Using the async.js async.series() call But while it will execute the calls (print 'success'), it'll find or create a Factor in the DB very infrequently, so it

Sails.js: Nested MongoDB queries

旧街凉风 提交于 2019-12-24 13:24:42
问题 I am using Sails v0.11 and am developing an standalone importer script in order to import data to mongoDB and - that is now the not-working part - build the associations between the models. For this process I introduced temporary helper properties in the models in order to find the associated records and replace them by in real MongoDB _ids. The script starts Sails in order to be able use its features (waterline, etc.): var app = Sails(); app.load({ hooks: { grunt: false }, log: { level:

Simple Sails.js and Android Example

自古美人都是妖i 提交于 2019-12-24 13:19:34
问题 I am really struggling with opening a socket connection using sails.io and android. What I am trying to achieve at the moment is simply to print the socketid in the console of the sails.js server. Android Side: I am using nkzwa's socket.io.client library ( compile 'com.github.nkzawa:socket.io-client:0.4.2') This is the code that I am using in android inside an AsyncTask: private Socket mSocket; { try { mSocket = IO.socket("http://192.168.0.80:3000/batches/"); } catch (URISyntaxException e) {}

How to setup different environments and corresponding configurations under sails.js?

馋奶兔 提交于 2019-12-24 13:16:10
问题 I'm in the process of migrating a 2010 RoR app to Sails.js. From the face of it Sails.js looks like the best framework for migrating the app to Node.js platform. In the process, I came across a limitation - it seems like sails only caters to a development environment through local.js and a production environment. Under RoR, I had a environments folder under config, which contained dev, test, staging, production, etc. ruby files that contained constants, logging levels, etc. defined for that

CSRF mismatch when POSTing to sails backend from Angular JS

蹲街弑〆低调 提交于 2019-12-24 12:52:02
问题 In angular, I obtain a CSRF token like this: // Get CSRF token and set as header var csrfRequest = Auth.getCSRF().then(function(data){ console.log(data.data._csrf); $rootScope.csrf = data.data._csrf; }); Which logs the new token to the console (this works fine). Then, I try to login to a sails.js api. Here's the request: POST /auth/login HTTP/1.1 Host: localhost:1337 Connection: keep-alive Content-Length: 108 Pragma: no-cache Cache-Control: no-cache Accept: application/json, text/plain, */*

Sails.JS + MySQL: Unknown column 'NaN' in 'where clause'

混江龙づ霸主 提交于 2019-12-24 12:49:20
问题 this is my first time using sails.js with mySQL database and I'm really confused about this error. I have a controller & model called 'company'. It relates to table 'company' in mySQL database. The table itself has one-to-many associations with two tables called 'module' and 'user' (each user/module must connect with one company id). I've set the foreign key in the MySQL database. The problem is.. each time I open any page/action from this controller, there is this error: error: Sending 500 (

http.trustProxy flag not recognized when deploying sails app in production mode

故事扮演 提交于 2019-12-24 12:08:05
问题 I have a sails 1.0.2 app, which runs on an Ubuntu 18.04.1 LTS instance. Further, a reverse proxy (Apache) redirects HTTPS (443) requests from the public-side to my specified sails port (4433 in my case). This works fine when I lift the app using sails lift --port=4433 , the CLI states that the app is listening to port 4433 - when I visit my app from the outside via https(/:443), I can see my app. According to sails documentation, I set up my production environment in env/production.js and

Passport-Facebook giving two different facebook Id

无人久伴 提交于 2019-12-24 11:27:30
问题 I tried to implement facebook OAUTH for my applications(Web and Mobile) using Sails.js/Node.js and Mongo as my backend. I wrote a dedicated function to access the endpoints for each app cause the webApp needs a callback URL and the mobile doesn't. My code screenshot is available below. But, I noticed the two gives me two different Facebook id. I am confused, shouldn't the facebookId be unique? I am using these two modules FacebookStrategy = require('passport-facebook').Strategy