Skip to content

Restful API

Francois edited this page Dec 21, 2025 · 2 revisions

Presentation

REST (Representational State Transfer) is a standard to describe how to implement networked applications (consumed by other applications or a frontend for instance). It almost always relies on HTTP protocol.

Key benefits for this project:

  • maintanability : separation of concerns between the frontend and backend

Installation

Documentation

OpenAPI heps to generate interactive documentation from decorators in the codebase (in controllers and DTOs).

Decorators

on controller class :

  • @ApiTags to group endpoints under a category (i.e. "users")
  • @ApiBearerAuth() if the endpoint requires authentication
  • @Controller

on function

  • method such as @Get(:param)
  • @ApiOperation with attributes summary : description
  • @ApiParam with attributes name, description
  • @ApiQuery
  • @ApiResponse (status, description, type: DTO) for each possible case

on DTO fields

  • @ApiProperty (example, description, required)

Do's & Don'ts

โœ… Do โŒ Don't
Use DTO for request bodies and response objects Expose database entities
Use standard HTTP codes
Describe params
Document error cases Ignore 4xx and 5xx

Note

RESTful API are stateless, so we should not store client context (such as 'current xxx', ...)

Resources

Type Resource Notes
๐Ÿ“„ Official Specs 3.1.1 Main reference
๐Ÿ“ฆ @fastify/swagger to check
๐Ÿ“ฆ @scalar/fastify-api-reference to check
๐Ÿ’ป Pro example MS Azure guidelines - not checked
๐ŸŽฅ Documenter avec OpenAPI php but transferable to project

Legend: ๐Ÿ“„ Doc, ๐Ÿ“˜ Book, ๐ŸŽฅ Video, ๐Ÿ’ป GitHub, ๐Ÿ“ฆ Package, ๐Ÿ’ก Blog

๐Ÿ—๏ธ Architecture

๐ŸŒ Web Technologies

Backend

Frontend

๐Ÿ”ง Core Technologies

๐Ÿ” Security

โ›“๏ธ Blockchain

๐Ÿ› ๏ธ Dev Tools & Quality


๐Ÿ“ Page model

Clone this wiki locally