Book Image

Mastering Web Application Development with Express

By : Alexandru Vladutu
Book Image

Mastering Web Application Development with Express

By: Alexandru Vladutu

Overview of this book

Table of Contents (18 chapters)
Mastering Web Application Development with Express
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating RESTful URLs of the application


Now that we know what the application requirements are, we can move on to designing its API.

An important principle when creating RESTful URLs is to avoid using verbs in the URLs. Instead of having URLs such as /notes/getAll or /notes/deleteNote, we need to leverage existing HTTP methods such as GET or DELETE.

The thing to remember here is that we need to use nouns for resources and operate on them using HTTP methods. Let's apply this theory in practice and see how our endpoints will look; refer to the following table:

URL

HTTP Method

Action

/users/<username>

GET

This is used to get the public details of a specific user

/users

POST

This is used to create a new user

/users/<username>

PATCH

This is used to partially update the authenticated user

/users/<username>/notes

GET

This is used to retrieve the list of public notes shared by a specific user

/users/<username>/notes/<note_id>

GET

...