Updating the API engine

Now that we are done with the web app development, we will update the API engine to add the device's API and data service, along with web sockets.

Open api-engine/server/routes.js; we will add two routes here. Update api-engine/server/routes.js, as follows:

'use strict'; 
 
var path = require('path'); 
 
module.exports = function(app) { 
  // Insert routes below 
  app.use('/api/v1/users', require('./api/user')); 
  app.use('/api/v1/devices', require('./api/device')); 
  app.use('/api/v1/data', require('./api/data')); 
 
  app.use('/auth', require('./auth')); 
}; 

Now, we will add the definitions for these routes. Inside the api-engine/server/api folder, create a new folder named device. Inside the device folder, create a new file named ...

Get Practical Internet of Things with JavaScript now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.