In the previous section, we completed the implementation for select, insert, update, and delete functions from the database side. Now we are going to route each of the HTTP paths into these database functions, we can complete the Node.js RESTful API at this stage and then try to execute the API:
- Let's create a route file as shown in the following code block:
[root@ip-172-31-95-213 node-api]# vi routes/index.js
------------------------------------------
var express = require('express');
var router = express.Router();
var path = require('path');
var db = require('../queries');
router.get('/api/atm-locations', db.getAllATMLocations);
router.get('/api/atm-locations/:id', db.getSingleATMLocation);
router.post('/api/atm-locations', db.createATMLocation);
router.put('/api/atm-locations/:id', db.updateATMLocation);
router.delete('/api/atm-locations/:id', db.removeATMLocation);
module...