michelmansour / virgil

A delightful way to share, discuss, and annotate poetry
MIT License
2 stars 2 forks source link

Consider plural collection names #18

Open alex-knowles opened 7 years ago

alex-knowles commented 7 years ago

Currently, the following routes exist:

method path
POST /login
GET /api/comments/:poemId
POST /api/comments/:poemId
GET /api/session
GET /api/queue
POST /api/queue
GET /api/poem
GET /api/poem/:poemId
POST /api/poem
GET /*

Note that all collection names, except for "comments", are singular.

However, RESTful naming conventions recommend the plural form for resource collections.

Excerpt:

A collection resource is a server-managed directory of resources. Clients may propose new resources to be added to a collection. However, it is up to the collection to choose to create a new resource, or not. A collection resource chooses what it wants to contain and also decides the URIs of each contained resource.

Use “plural” name to denote collection resource archetype.

Consider using the following plural forms instead:

alex-knowles commented 7 years ago

This might warrant a separate issue in itself, but on the topic of path names, I suggest categorizing "comments" as a sub-collection of poems.

For example, to request an index of comments for a given poem, a RESTful client might expect the form:

GET /api/poems/{id}/comments

michelmansour commented 7 years ago

I agree on the plural resource names.

I suggest categorizing "comments" as a sub-collection of poems.

However, I don't think this particular change makes sense for our use cases. We really need to flesh it out some more, but a poem could have different sets of comments on it in different contexts. For example, a poem could exist in the global database and have comments on it in a non-session context. It could also be part of multiple clubs' sessions and have comments on it in the context of each of those sessions.