Sails.js interview questions

Sails.js interview questions

Read Best Sails.js interview questions

Download Sails.js interview questions PDF

Below are the list of Best Sails.js interview questions and Answers

Sails.js is an open-source model view controller means the MVC web application framework developed atop the Node. js environment which is designed to make it easy to build custom, enterprise-grade Node. js web applications and APIs. It is a popular, lightweight server-side technology that allows developers to write blazing fast, scalable network applications in JavaScript.

Some of the features of Sails.js are as follows:

  • Powerful associations.
  • Auto-generate REST APIs.
  • Support WebSockets with no additional code. 
  • Declarative, reusable security policies. 
  • Front-end is agnostic. 
  • Flexible asset pipeline.

 

You can create an application instance in Sails.js with the help of the inbuilt application method present in Sail.js.

The Sails app lifecycle states that the Sails core has been iterated upon several times to make it easier to maintain and extend. As a result, it has a very particular loading order, which its hooks depend on heavily.

In Sails, Assets refer to static files such as js, CSS, images, etc. these files are placed in the assets/ folder. When you lift your app, add files to your assets/ folder, or change existing assets, Sails' built-in asset pipeline processes and syncs those files to a hidden folder ( . tmp/public/ ).

sails.getBaseUrl() is the sail.js command which is used to get application BaseUrl in Sails.js.

Waterline is the by default name of ORM in Sails.js as it is implemented in the sails-hook-orm dependency. Waterline is a new kind of storage and retrieval engine as it strives to inherit the best parts of ORMs.

The steps to configure a database in Sails.js are:

  • First, locate the config folder in your root. Then open connections.js
  • Save file
  • Go to your root folder and run the following command: $ npm install sails-mysql --save
  • Now you can use mysql_connection as a connection name in your model config. When you lift your app using the following command: $ sails lift.

In Sail.js a hook is a Node module that adds functionality to the Sails core and also defines the requirements a module must meet for Sails to be able to import its code and make the new functionality available. Hooks are of three types in Sail.js, these are as follows:

  • Core hooks
  • App-level hooks
  • Installable hooks 

In Sail.js, Services are stateless libraries of functions that you can use from anywhere in your Sails app. These are generally pieces of reusable code that can be shared by your controllers.

You can create an Installable Hook in Sails.js with the help of the following steps:

  • Choose a name for your new hook. It must not conflict with any of the core hook names.
  • Create a new folder on your system with the name sails-hook-<your hook name>. 
  • Create a package.json file in the folder.
  • Write your hook code in the index.

 

In sail.js Middleware is a part of an MVC framework that refers more specifically to code that runs before or after your route-handling code and making it possible to apply the same piece of code to multiple routes or actions.

You can generate a controller in Sails.js with the help of sails-generate from the Sails command-line tool. It is used to quickly generate a controller in Sail.js.

In sail.js, the generators are basically a type of plugin for the Sails command line. It controls which files get generated in your Sails projects through templates whenever you run sails new or sails generate, and also what those files look like.