Company
Date Published
Author
Andrew Morgan
Word count
5065
Language
English
Hacker News points
None

Summary

The summary is as follows: This post builds on from the previous ones by using Express to build a REST API so that a remote client can work with MongoDB. The REST API uses the javascripts/db.js database layer implemented in Part 2 to access the MongoDB database via the MongoDB Node.js Driver. The Mongopop application uses Express to perform two functions: send the front-end application code to the remote client when the user browses to our app and provide a REST API that the front-end can access using HTTP network calls, in order to access the database. The REST operations implemented in Express for Mongopop include GET, POST, PUT, and DELETE methods. The application uses Express routes implemented for the Mongopop REST API, with each route path mapped to an HTTP method. The Mongopop REST API provides several endpoints, including /pop/ip, /pop/config, /pop/addDocs, /pop/sampleDocs, /pop/countDocs, and /pop/updateDocs. Each endpoint has a specific purpose and returns different data in response to the client's request. The application also uses middleware to parse JSON received in requests and error handling for queries sent to an undefined route.