January 2018
Intermediate to advanced
332 pages
7h 36m
English
We can now add a route to access this graph and its corresponding shortestPath method. Let's first create the route under routes/references and add it as a middleware to the web server:
var express = require('express');var app = express();var bodyParser = require('body-parser');// register endpointsvar references = require('./routes/references');// middleware to parse the body of input requestsapp.use(bodyParser.json());// route middlewareapp.use('/references', references);// start serverapp.listen(3000, function () { console.log('Application listening on port 3000!');});
Then, create the route as shown in the following code:
var express = require('express');var router = express.Router();var Graph = require('../utils/graph' ...
Read now
Unlock full access