Skip to content

Latest commit

 

History

History
77 lines (66 loc) · 2.47 KB

004-core-features.md

File metadata and controls

77 lines (66 loc) · 2.47 KB

004 Core features

^ Back to parent

List

  • GET /products

    • Server initializes db connection (using secrets)
    • Server listens to port
    • Server default route --> 404
    • Server default error handler --> 500
    • Product model can select many from db
    • Product model converts db result to array
    • Product list view serializes array to JSON
    • Server controller for route
      • empty array result is not an error
      • on applicative error --> 500
      • queries db throught model
      • serializes response body throught view
      • returns response body --> 200
    • Server route for GET /products
  • POST /products

    • Product model can validate fields
      • invalid --> 422
    • Product model can insert to db
    • Product model can select one from db
    • Product model converts db result to obj
    • Product view serializes obj to JSON
    • Server route for POST /products
    • Server controller for route
      • on applicative error --> 500
      • inserts into db throught model
      • duplicate error --> 409
      • missing fk error --> 409
      • serializes response body throught view
      • returns response body --> 201
  • GET /products/{id}

    • Param middleware: validate id (later addition)
    • Param middleware: pre fetch product (later addition)
    • Server controller for route
      • empty result is an error --> 404 (later edit)
      • no pre fetched product --> 404 (later edit)
      • on applicative error --> 500
      • query db throught model (later removal)
      • serializes response body throught view
      • return response body --> 200
    • Server route for GET /products/{id}
  • PATCH /products/{id}

    • Product model can validate changes
      • invalid --> 422
    • Product model can update in db
    • Server controller for route
      • no pre fetched product --> 404
      • on applicative error --> 500
      • update db throught model
      • serializes response body throught view
      • return response body --> 200
    • Server route for PATCH /products/{id}
  • DELETE /products/{id}

    • Product model can update as removed in db
    • Server controller for route
      • on applicative error --> 500
      • update db throught model: deleted flag
      • return response --> 204
    • Server route for DELETE /products/{id}
  • Integrated docker+compose serve/deploy

  • Branch & version appropriately

Next

Optional features