Skip to content

An example of API architecture for my web API course

Notifications You must be signed in to change notification settings

Vagahbond/RESTpastrop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RESTPasTrop

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
  • Buisness logic
    • Users
    • Reservations
    • Locations

Run

Required

  • Docker installation with docker compose

Commands for developping

** 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

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

Documentation is automatically generated using JSDOC in the code. It can be accessed through /doc.

Insomnia

insomnia.json should contain a list of existing requests with documentation for them.

REST

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

entities

erDiagram
    USER ||--o{ LOCATION : owns
    RESERVATION }o--|| LOCATION : "located at"
    USER ||--o{ RESERVATION : "made"
Loading

About

An example of API architecture for my web API course

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published