O'Reilly logo

Mastering JavaScript Single Page Application Development by John Moore, Philip Klauzinski

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 a RESTful API

Let's do a little more work setting up our SPA by building out some resourceful routing as part of a RESTFul API that we can connect later to our database and our client-side code. We're lucky that Express has such a vibrant community of developers building many add-ons, and we're going to use one for resourceful routing.

Installing resourceful routing

The first thing we need to do is to install our module, which will provide us with some resourceful routing:

npm install resource-routing -save

This installs the resourceful routing plugin we're going to use, and saves a reference to the package.json file.

Next, we need to do some setup in our app.js file:

var express = require('express'); var path = require('path'); var favicon ...

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