O'Reilly logo

Sails.js Essentials by Shaikh Shahid

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing the application

Let's create our new Sails.js app, as shown in the following:

sails create <app name>

Once the app is created, we need an API to deal with our status updates. Let's create that as well:

sails generate api Message

Sails.js will create controller and model in the respective folders. Let's define the model first. Here is models.js in the /api/models/ folder:

module.exports = {
  attributes: {
  name  : { type: 'string' },
  message : { type: 'string' }
  }
};

Before going to the controller and Socket modules, let's look at the view first. The user interface will be quite simple. We will have a textbox to accept the name and a text area to accept the status messages. It will look similar to the following diagram:

The following is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required