A RESTful API is an API that uses HTTP requests to GET, PUT, POST, and DELETE data. Although SOAP has been the preferred and chosen option by many companies, for others it is too complex and inflexible. For this reason, REST-based services are beginning to be used to display massive amounts of data and this is the goal that we have in this book.
Our design of a RESTful API for Node.js will include the endpoints shown in Table 3-1.
URL | HTTP Verb | Action |
/api/atm-locations /api/atm-locations/:id /api/atm-locations /api/atm-locations/:id /api/atm-locations/:id |
GET GET POST PUT DELETE |
Return ALL ATM machines Return a SINGLE ATM machine Add an ATM machine Update an ATM machine Delete an ATM machine |
Table 3.1 – The RESTful services
Let's check it out using the following steps:
- Let's create an Express Node.js app with the help of the following command:
[root@ip-172-31-95-213 node-api-postgres]# npm install express-generator -g
- Express is...