Now we have automated tests for the model and a user-defined module which makes use of them. This ensures the stability of the module and makes it ready for wider adoption.
It is time to build a new Express-based application and add a route, exposing the new module to it:
const express = require('express'); const router = express.Router(); const catalog = require('../modules/catalog'); const model = require('../model/item.js'); router.get('/', function(request, response, next) { catalog.findAllItems(response); }); router.get('/item/:itemId', function(request, response, next) { console.log(request.url + ' : querying for ' + request.params.itemId); catalog.findItemById(request.params.itemId, response); }); router.get('/:categoryId', function(request, response, next) { console.log(request.url + ' : querying for ' + request.params.categoryId); catalog.findItemsByCategory(request.params.categoryId, response); }); router.post('/', function...