O'Reilly logo

Practical Internet of Things with JavaScript by Arvind Ravulavaru

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required