Menu

Basics of Building a CRUD API with Node (no framework)

DEV Community: koa·Alex Merced·8 months ago
#46Ikjeyv
#dev#class#response#request#code
Long article (3808 words) — no AI summary yet.
Reading 0:00
15s threshold

In this tutorial we once again create a full CRUD api without a database. In this article we won't use a pre-existing framework but the standard node libraries that underpin all our favorite frameworks.

Summary of RESTful Convention

THe restful convention gives us a blueprint of making the basic routes for CRUD (Create, Read, Update, Delete) functionality in a uniform way.

API Restful Routes

Name of Route Request Method Endpoint Result

Index GET /model returns list of all items

Show GET /model/:id returns item with matching id

Create Post /model creates a new item, returns item or confirmation

Update Put/Patch /model/:id Updated item with matching ID

Destroy Delete /model/:id Deletes item with matching ID

If we weren't build an API but instead rendering pages on the server there would be two additional routes. New, which renders a page with a form to create a new object, submitting the form triggers the create route.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.