I would propose following changes that would allow the frontend for easier and cleaner development.
Endpoint changes
Projects
Repositories
In essence
- I would suggest using plural names for every endpoint that supports collections.
- When an endpoint returns a collection, return the collection as root, without any key (eg /repositories does not return
"repo": [], but rather []
- Rename
name_id -> id for every endpoint.
- Use camelCase for every property name.
- Change all update endpoints to a PATCH, where you only have to send the fields that have to change.
- Add hyperlinked data instead of an array of ids (this means adding a separate endpoint)
- eg:
repos: [10, 11] -> repositories: "https://url/projects/2/repositories"
- so not a list of links, that would make things harder in the frontend
- this also saves a lot on request times, certainly when a lot of repositories will be linked (HTTP2 is a thing but a lot of requests will take quit a significant time)
Error handling
When an error occurs, it should be displayed in a proper way in the frontend.
I would suggest the following format:
// A general error returns errors that are not linked to any input field.
generalErrors: [
{
message: "Something general has occurred."
}
],
// A field error returns an error that is linked to a body input field.
// (eg name or description when creating a project)
inputErrors: [
{
input: "name",
message: "Name cannot be longer than 3 characters."
}
]
I would propose following changes that would allow the frontend for easier and cleaner development.
Endpoint changes
Projects
GET /projects
POST /projects
GET /projects/:id
DELETE /projects/:id
PATCH /projects/:id
GET /projects/:id/repositories
GET /projects/:id/issues
GET /projects/:id/pullrequests
Repositories
GET /repositories
GET /repositories/:id
POST /repositories/:id/link/:projectId
POST /repositories/:id/unlink/:projectId
POST /repositories/sync
In essence
"repo": [],but rather[]name_id->idfor every endpoint.repos: [10, 11]->repositories: "https://url/projects/2/repositories"Error handling
When an error occurs, it should be displayed in a proper way in the frontend.
I would suggest the following format: