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

Developing web server using Express

Express is a web development framework built on top of Node.js. Express is also the core module used in developing Sails.js. Before getting into the detail of Sails.js, let's briefly go through Express.

Using Express to develop web server

Let's develop our web server using Express. The following is a sample package.json:

{
  "name": "expressServer",
  "version": "0.0.1",
  "dependencies": {
    "express": "^4.13.3"
  }
}

Switch to the project directory and run the npm install command in order to install Express in the project. Let's develop our basic server file, as follows:

// load express module. var express = require("express"); var app = express(); // Always use express inbuilt router. var router = express.Router(); router.get('/',function(req,res){ ...

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