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.
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 = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var isJSON = require('./utils/json');
var routing = require...