O'Reilly logo

Building APIs with Node.js by Caio Ribeiro Pereira

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

©  Caio Ribeiro Pereira 2016

Caio Ribeiro Pereira, Building APIs with Node.js , 10.1007/978-1-4842-2442-7_6

6. CRUDify API Resources

Caio Ribeiro Pereira

(1)São Vicente - SP, São Paulo, Brazil

In this chapter, we’ll continue to explore the new functions from Sequelize and also organize the API’s routes and some middlewares of Express. The create, read, update, delete (CRUD) will be built using the Tasks and Users models.

Organizing Task Routes

To start this refactoring, let’s explore the main HTTP methods to CRUDify our application. In this case, we are going to use the functions app.route("/tasks") and app.route("/tasks/:id") to define the path: "/tasks" and "/tasks/(task_id)".

These functions allow us to use nested functions, reusing the routes ...

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