API made accprding to those Specifications to give my students an example of how they could do a project I gave them.
** /!\ THIS IS STILL WORK IN PROGRESS /!\ **
Tasks :
- Boilerplate
- Files Architecture
- Users CRUD
- Reservations CRUD
- Locations CRUD
- Error Handling
- Documentation
- Validation
- Locations Validation
- Users Validation
- Reservations Validation
- Rights management
- Authorization
- Authentication
- Documentation
- Users
- Schema
- Endpoints
- Locations
- Schema
- Endpoints
- Reservations
- Schema
- Endpoints
- Users
- Buisness logic
- Users
- Reservations
- Locations
- Docker installation with docker compose
** Run for the first time **
docker compose up
** Stop the app **
docker compose down
** Reset the database (Will force execution of init.sql
) **
docker compose down --volumes
dev setup is not viable for production
Architecture was made according to the course with controller, repository and service layers and an added model for passing data between those.
.
├── bun.lockb
├── common
│ ├── db_handler.ts
│ ├── http_errors.ts
│ ├── middlewares
│ │ ├── error_middleware.ts
│ │ └── id_param_guard_middleware.ts
│ └── swagger_handler.ts
├── index.ts
├── locations
│ ├── controller.ts
│ ├── model.ts
│ ├── repository.ts
│ └── service.ts
├── package.json
├── reservations
│ ├── controller.ts
│ ├── model.ts
│ ├── repository.ts
│ └── service.ts
├── tsconfig.json
├── tsconfig.tsbuildinfo
└── users
├── controller.ts
├── model.ts
├── repository.ts
└── service.ts
Documentation is automatically generated using JSDOC in the code. It can be accessed through /doc
.
insomnia.json
should contain a list of existing requests with documentation for them.
This project includes:
- Explicit HTTP method related to their actions
- GET : retrieve
- PATCH : modify
- DELETE : remove
- POST : create
- Explicit resources names : last relevant word in the URL is the type of data you should expect to get.
- HATEOAS : The API can be browsed using link it gives for each entity
erDiagram
USER ||--o{ LOCATION : owns
RESERVATION }o--|| LOCATION : "located at"
USER ||--o{ RESERVATION : "made"