Questions tagged [sails.js]

Sails.js stands out as a cutting-edge web framework empowering developers to effortlessly construct tailor-made, top-tier Node.js applications. Emulating the MVC structure of Ruby on Rails and embracing contemporary, data-driven approaches to web app development, it takes customization and enterprise-grade solutions to unprecedented levels.

How can I access a remote model method within server.js in LoopBack?

My loopback models have a mix of remote methods and non-remote methods. I need to restrict calls in server.js so that only remote methods can be accessed, while denying access to non-remote methods. The code snippet below is from my server.js file. Curren ...

Keep moving forward in Sailsjs even after sending back a response with res.json();

It will keep running even if the condition is met and the code inside return res.json() gets executed. _.each(rooms, function(room){ if(room.users.length == users.length) { return res.json(room); // <-- returns but execution continues } ...

Navigating after logging in with sails-permissions in sails

As a newcomer to sails, I am currently exploring authentication implementation. Following the recommended steps, I set up everything and created a basic login form using jade: form(action="/auth/local", method="post") div input(name="identifi ...

Unable to display image on HTML page in Sails JS

In my current project, I am utilizing Sails Js and Mongo DB for development. When a user uploads an image and content for a blog post, I store it in the images folder and save the file destination along with the content to MongoDB. My goal is to display bo ...

What is the best way to identify and recover two separate client socket connections from the same user after a server restart?

Picture this scenario: A customer opens a browser tab and goes to page-x. As the customer remains on this page, I send out data through a socket specific to this page, which we'll call socket-context-x. Next, the customer opens another browser tab ( ...

Creating custom project structures with Sails.js 0.10 generators

When looking at the upcoming Sails.js 0.10 release, one exciting feature that stands out is the addition of custom generators (currently @ rc4). You can find a migration guide on Sails' GitHub page highlighting the benefits of these generators, but it lac ...

Create a Rest API and implement server-side rendering concurrently using SailsJs

I am exploring the potential of utilizing the SailsJs framework for nodeJs in order to create an application. Initially, my plan was to construct a REST API in Sails and utilize AngularJs for managing the Front-End. This API would also be beneficial for o ...

How to retrieve the count of documents in a populated collection using Sails.js with MongoDB

I have two models category and inventories and they are associated. The command I used is: Category.find(query).populate('inventories',{select: ['id']}); This command returns the following result: "categories": [ { "inventories": [ { ...

sails-auth failing to create models, policies, and other essential resources

After setting up a fresh Sails application, my intention was to incorporate passport for authentication. However, using sails-auth doesn't seem to generate the necessary files as indicated in the documentation. Sails version: 0.12.14 During the installat ...

The $pull functionality of Waterline ODM used to query and update a MongoDB database

The Waterline feature of Sails allows you to designate an entity's attribute as an 'array' type: module.exports = { attributes: { items: { type: 'array' } } } In MongoDB, the $pull operator is available for update queries, enabling the removal ...

Utilizing Socket technology in combination with Sails JS and React JS

Currently, I have a live bidding system in place. On the bidding page, we display both the base price and current bid price of an item. Whenever a user updates the price of an item, I would like that new price to automatically reflect for all customers who ...

"Combining Cloud9 with sails.js and phpMyAdmin for optimal development experience

I'm facing an issue while trying to set up a basic sails.js application in the Cloud9 environment and connecting it to MySQL. Here are the steps I've followed: Created a Cloud9 project Installed sails: npm -g install sails Created the project: ...

Eliminating the need for session and socket pooling in Sails.js

Hello, I am currently developing my rest api app using sails. I came across an interesting article on improving Node.js performance, which you can find here. One of the suggestions in point 2 was to eliminate socket pooling by setting options.agent to fal ...

Is Node.js Express the best choice for building a RESTful API? And does Express utilize controllers

I am currently working on creating a community platform tailored to a specific local audience, similar to a lightweight "social network." For this project, search engine optimization is not a priority, allowing me to focus exclusively on users who have Jav ...

How can I utilize customToJSON in Sails 1.0 within an Action2 function?

Currently, I am facing an issue with my user model that requires the implementation of a customToJSON method to remove the password field from the returned JSON object. Everything works fine when I include "responseType" in the "exits" with a value of "jso ...

Upon hitting submit, the form remains unresponsive

I have been developing a permissions system for my NodeJS project (Using the SailsJS MVC) and encountered an issue. After resolving my initial error as detailed here, I am now facing a problem where the form is unresponsive. It neither shows an error in th ...

Ways to ensure the security of my RESTful API?

I am currently working on an API built with node.js & express.js. At the moment, the API is unsecured which allows anyone to access and manipulate records using GET, POST, PUT, and DELETE requests. One of the challenges I am facing is that my REST API sho ...

Is it possible to exclude specific URLs from CSRF protection in sails.js?

I am currently integrating Stripe with my sails.js server and need to disable CSRF for specific URLs in order to utilize Stripe's webhooks effectively. Is there a way to exempt certain URLs from CSRF POST requirements within sails.js? I have searched ...

No assets detected in sails.js

Recently, I began a new sails project using 'sails new project --linker'. Initially, everything was functioning correctly but today I encountered a problem. Every time I start the server with 'sails lift', I now receive a 404 error for all my javascript f ...

Initializing Angular variables

My Angular controller has a variable called $scope.abc. The backend I'm using is Sails. The initial value of $scope.abc can be set by the backend when the page is first generated. Once the page is displayed, the user may or may not change this value ...

Guide to combining an Angular 2 (angular-cli) application with Sails.js

I am looking to integrate the app created using angular-cli with Sails.js. My background is in PHP, so I am new to both of these frameworks. What are the steps involved in setting them up together? How can I execute commands like ng serve and/or sails li ...

Explaining the Contrast: `req.body` vs `req.params.all()` in Sails.js

Can you explain the distinction between using req.body and req.params.all() within a sails controller? ...

Should we integrate a MongoDB database calculation app with a POST Controller in sails.js?

The primary function of the application interface is to provide variables that have been initially posted by the client, as well as any subsequent database calculations carried out in real time by a specialized engine. Is it possible to integrate this eng ...

Guide to integrating Google APIs with SailsJS

Can someone help me calculate the distance between 2 coordinates using GMap API? I am trying to figure out how to retrieve data from a URL. https://maps.googleapis.com/maps/api/distancematrix/json?origins=Seattle&destinations=San+Francisco&key={{m ...

Encountering a problem with deploying a sails.js application on Heroku due to an npm error related to the package "sailshq

Starting with the current setup on my development machine: Node version: 8.4.0 Npm: 5.3.0 (includes Node 8.4) Sails: ~0.12.13 Source control system: Github Deployment host: Heroku I followed this guide: (excluding the heroku git part, utilizing githu ...

Enhance your Sails.js model by incorporating a custom instance method as a new property

As a JavaScript programmer still learning the ropes, I encountered a challenge while working with Sails.js and creating a model. Here is what I have so far: module.exports = { tableName: 'FOO_TABLE', attributes: { FOO: 'st ...

A PHP framework designed for creating RESTful CRUD operations

I am a big fan of using SailsJS () for my projects. One of the reasons I like it so much is because it automatically creates a RESTful CRUD API. However, when working with small clients, I often find myself operating in a different environment such as Apac ...

What is the process for invoking a microservice (constructed in express js) from an angular application that is currently communicating with a sails js backend?

I had initially developed an application with Angular frontend and Sails JS backend. However, I recently separated some of the backend functions into a micro-service using Express. Now, I am looking for guidance on how to call these functions from my mai ...

Error: authentication failed with local passport

I've been experimenting with passport-local for authentication in my Sails project. Here is an excerpt from my controller: passport.authenticate('local', function(err, user, info) { if ((err) || (!user)) { res.json({message: 'Unable to authenticate'}); ...

Controlling Dependencies within SailsJS

Is there a way to effectively handle dependencies in a Sails.JS project? I have been utilizing the convenient feature that automatically connects assets from the assets folder to the appropriate templates. However, when I use bower / npm install to acqui ...

Navigating the Seas of Angular Frontend

After extensive research, I have been unable to find the precise answer I am seeking. Upon beginning my journey with Sails app development (a new venture for me), it came to my attention that the framework creates its own frontend using EJS by default. T ...

Is it possible for remote Node.js applications to communicate in real-time using full-duplex messaging via WebSockets

With no human involvement, both Endpoint A and Endpoint B are standalone Node.js applications operating independently. Endpoint A is tasked with establishing a secure web socket connection with Endpoint B and ensuring it remains active 24/7. Each endpoin ...

Error received on Node.js controller when calling Jquery getJSON from Ajax form

I have a Node.js / Sails.js application with a client-side form that submits to a Controller using jQuery ajax: $(function () { $("form").submit(function (e) { e.preventDefault(); var form = $(this); $.ajax({ url: ...

Developing an ASP application using the MVP pattern to return JSON data can be transformed into a S

I’m looking to incorporate the following code into a sails js Controller public JsonResult GetEvents() { //Using MyDatabaseEntities as our entity datacontext (refer to Step 4) using (MyDatabaseEntities dc = new MyDatabaseEntities()) { ...

Exploring the controller logic in Sails.js index.ejs

I'm struggling to understand how to integrate dynamic logic into the homepage of my Sails.js application. Currently, the homepage is static, but I want to display data on the index.ejs page. I have a MainController with an index function that retrieve ...

Node-webkit: The perfect solution for creating applications that seamlessly transition between web and desktop environments using a single code

Given the task at hand, I have been presented with the following considerations: Develop a desktop application using Nodeweb kit. Also develop a web application using the same code base. Both applications should have an identical appearance. Both apps mu ...

What are the methods for implementing calculated fields in Waterline for the purpose of sorting?

I'm currently working on sorting my query for the Reddit hot algorithm. The sorting is based on time, and unfortunately I am unable to use beforeUpdate or beforeCreate hooks in this case. I need to incorporate a calculation while querying, but so far I hav ...

add a fresh entry into sails.js

I encountered an issue while trying to create a new record. The error message I received is as follows: TypeError: User.create(...).fetch is not a function Below is my UserController.js code snippet for the create function: create: async function(req,r ...

Guide to including configuration settings in locals for Sails.js

Currently working on a webapp with Sails.js, I am looking for ways to set up different configurations for development and production modes. Initially, I attempted to store the configuration key in config/local.js, but unfortunately, it did not yield the de ...

Having fun with node.js in a boat sailing through the digital waters of sails.js, guided by the

Currently, I am attempting to understand how promises function in sails. So far, I have been successful in passing data from waterline queries using .then, however, I have run into an issue when trying to use .spread. Specifically, I am receiving a 'f ...

Error message from sails.js: `req.target` is not defined

Experiencing a problem where req.target sometimes returns undefined, causing issues with other functionalities dependent on req.target. Seeking assistance to resolve this issue. Appreciate any help! ...

Combining two JSON objects with sailsjs-nodejs to create a single merged object

Hello everyone, I am a beginner with Sailsjs-Nodejs. Currently, I have two JSON Objects in my controller that I need to merge/join in order to create a third object to send as a response. The output when using res.send(obj1) is: [ { total_fare: "37 ...

Exploring the Benefits of Implementing Etag in Sails.js

Currently, I am seeking ways to enhance the cache capabilities of my Sails application. Sails generates an Etag with its response. However, despite sending a GET request with an 'if-None-Match' header containing the Etag from the previous respon ...

Leveraging Sequelize for Redshift Integration

Can Sequelize be integrated with Redshift? If not, what other options are available? I am searching for an ORM suitable for Node.js that includes transaction support, ruling out Sails.js. While considering Bookshelf as an alternative, it also lacks compa ...

Tools for parsing command strings in NodeJS

Currently, I'm utilizing SailsJS for my application. Users will input commands through the front-end using NodeWebkit, which are then sent to the server via sockets. Once received, these commands are parsed in the back-end and a specific service/controlle ...

Managing JWT tokens for secured pages using Sails.js

In an effort to enhance security in my system, I decided to implement JWT token authentication. For the front-end, I opted for statellizer. Once a user logs into the system, a token is generated like this: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI ...

SailsJS fails to transpile Bootstrap.js in a timely manner

In my backend development with Sails JS, I am utilizing ES6/7 and have created a class to handle background tasks. After reading a post on StackOverflow (link), it was recommended to initiate background tasks in config/bootstrap.js. Following this advice, ...

Steps to invoke another service (function) prior to calling the res.view() function in sails JS:

I am looking to execute a separate function, like a Service function, before Sails renders the page into HTML. Please refer to the controller code below... var MYController = { index: function(req, res, next) { req.flash("error", "Testing hello ...

What is the method to retrieve body in express.js GET call?

When using sails.js framework, which internally utilizes express.js, I encountered an issue while sending a body in a GET request. The command I used was: curl -u username:password -i -H "Accept: application/json" -X GET -d "msisdn=32323" http://localhost ...

Order the data by the updatedAt attribute in sails-dynamodb

An issue has arisen where I need to organize found elements based on the updatedAt field, which is automatically created and updated. Below is the code in question: Model: module.exports = { attributes: { id:{ type: "string" ...

Sails.js's powerful full text search capability

Can Sails.js and/or Waterline support full text search? While PostgreSQL does support full text search, it appears that the PostgreSQL adaptor for Waterline may not have this feature. Is an efficient full text search achievable with Waterline's cont ...

The response data from the API is filled with mysterious escape characters

Obtaining data from the API response looks like this: { "ORG_ID":"165", "DEPOT_NAME":"Pesto", "DEPOT_SHORT_NAME":"PSD", "PROD_ID":"709492", "DESCRIPTION":"EX CL (2X14) U17SH365", "PRICE":"3708.55", ...

Guide to organizing code for a REST API using Express.js

Recently, I have been working on developing a REST API using Sails.js. As I outlined the resources needed for my application, it struck me that many frameworks (based on Express) are proficient at handling single resources. However, in most cases, I found ...

What is the best way to differentiate between a JSON object and a Waterline model instance?

Note: I have posted an issue regarding this on the Waterline repo, but unfortunately, I have not received a simpler solution than my current workaround. Within my User model, along with default attributes such as createdDate and modifiedDate, I also have ...

Sails.js suddenly crashed after being cloned from the repository

When I added my sails.js application to git and cloned it onto another desktop, the application stopped functioning correctly. Although I could run the sails lift command successfully, the login page failed to load properly: https://i.stack.imgur.com/YEhp ...

How can I set up an access token to circumvent the login page in Sails.js?

My SailsJS website has authentication implemented through a form where users are required to input their email and password. This code snippet is inspired by ActivityOverloard 2.0 example code Login login: function(req, res) { console.log("Login hehe ...

Sailsjs middleware that handles parsing of res.body data

I am a newcomer to JavaScript and recently started working with the sails framework. In my middleware, I am attempting to parse the HTTP response body to add a job to the celery queue. Despite following the documentation for skipper-, I continue to encount ...

What are the steps to create offline documentation for sails.js?

I am looking to integrate offline sails.js documentation into my system. You can find the official documentation for sails.js maintained at this Sails.js Documentation. According to their documentation, they use doc-templater for building the documentati ...

Optimal approach for organizing code in Sails.js (Node.js) applications

In my application, I have different parts such as Public API, Admin API, Admin Console (GUI), Private API, and Auth API (oauth2, local, socials). Although these components are distinct from each other, they share the same models. Some routes will experienc ...

What is the reason behind not being able to assign identical names to my SailsJS models and MySQL tables?

Recently diving into Sails JS, I found myself in unfamiliar territory with RESTful APIs. Following the guide, I created a User model to correspond with my existing users table. Adding attributes based on the table's columns was straightforward, and a GET r ...

Customizing file names in sails using req.file('file')

Currently, I am working on sails and have been able to successfully upload a file from the client to the server without using a form. I am utilizing fs.createReadStream('file') for this purpose. The file data is sent to the server and everything works fine ...

Do not use npm to install underscore libraries

How can I resolve the error I encountered while attempting to install packages using npm? Here is my packages file: "dependencies": { "express": "~3.3.6", "socket.io": "0.9.16", "jade": "~0.35.0", "less-middleware": "~0.1.12", "redis ...

Tips on safeguarding your templates while working with SailsJS and AngularJS

I am currently working on a web application using SailsJS and AngularJS. My project requires session management to track user login status. I came across this helpful tutorial and implemented an index.ejs view located in the /view folder. Within the index. ...

Having trouble with the command "npm install sails-mongo --save"?

When attempting to include sails-mongo in my Sails project by running npm install sails-mongo --save, I encountered the following error: ~/newWebApp $ npm install sails-mongo --save npm ERR! Linux 3.13.0-24-generic npm ERR! argv "node" "/usr/bin/npm" " ...

The persistent issue persists with the Sails.js Node server where the req.session remains devoid of any data, despite utilizing

Currently, I have an Ember app running on http://localhost:4200 and a Sails app running on http://localhost:1337. In order to set up a pre-signup survey policy in my Sails application, I have the following code in /api/controllers/ProcessSurveyController. ...

Automatic database migrations in Node.js

Having worked with Django for many years, I became accustomed to the convenience of their automigrations feature. As I recently delved into using SailsJS (a new territory for me), I noticed that it only offers support for alter in database migrations durin ...

Exploring the power of ES6 Generator functions in conjunction with SailsJS

Utilizing generators in nodejs is a game changer for me. They really enhance the server-side feel of my code. I've been experimenting with incorporating generators into my Sails app. Here's an example where my controller successfully works when I visit 'ge ...

Obtain the .exe file containing SailsJS and NodeJS framework

I recently developed a compact application with Node-WebKit. Now, I am looking to establish a backend service using SailsJS that can facilitate downloading an executable file of my app from a remote server. Can someone guide me on how to create this servic ...

Utilizing unique layouts for specific views in sails.js and angular.js

I am currently working on a Sails.js + Angular.js project with a single layout. However, I have come across different HTML files that have a completely different layout compared to the one I am using. The layout file I am currently using is the default la ...

How can I search for collection data that contains a specific string within objects of an array using MongoDB?

In my MongoDB collection, I have multiple records. Each record contains an array with objects that have various fields. Here is the structure of my collection: [{ "name" : "Karthik Thurairaja", "universities" : [ { "name" : " ...

How to install Sails js on an Ubuntu VPS with version 16.04?

I am currently using Sails JS (version 0.12.4) on my local Ubuntu machine with the following versions: node -v = v4.5.0, nodejs -v = v4.5.0, npm -v = 2.15.9, and sudo npm -v = 3.10.0 Everything works fine on my local setup, but I'm having trouble in ...

Having trouble installing dependencies through npm while constructing a docker image

When building an image from a Dockerfile, I encountered an error during the npm installation part of the process. Strangely, I can run the commands successfully outside of the image build environment. The source of this error is still unknown to me. I am ...

What is the best way to validate the body object when working with Actions2 in sails.js?

Just starting out with sails.js I understand that the inputs object allows actions2 to validate the request parameters. However, how can I access and validate the request body? For example, req.body. I know I can access this from this.req.body, but I was ...

Error: The function semrush.backlinks_refdomains does not exist as a valid function

Hey there! So I've been working with the SEMRUSH API and encountered an issue when trying to retrieve data using backlinks_refdomains and backlinks_refips. However, when I called the domain_rank function, it responded in JSON format without any proble ...

Learn how to effectively incorporate a file with a variable in EJS version 2

Recently, I encountered an issue while using EJS (version - 0.8.4) after making some changes to the file: node_modules/lib/ejs.js at line ~ 155 : The old code looked like this: if (0 == js.trim().indexOf('include')) { var name = js.trim().slic ...