brass/doc/design-decisions.md

1.3 KiB

Design Decision

Communication between Browser and Server via REST-like Endpoints and HTMX

  • https://htmx.org/essays/10-tips-for-ssr-hda-apps/
  • Name of endpoints is plural
    • "/locations" GET -> read all
    • "/locations/new" GET / POST -> create
    • "/locations/1" GET -> edit, POST -> update, DELETE -> delete CRUD
    • "/locations/assign" GET / POST for custom action
  • Modelling of models in code
    • see vehicle.rs
    • use of applicationError
    • return Options, where queries are bound to id or search input

Testing

User

  • CreatingNewUser_AsAdmin_SendsRegistrationMail

Data Layer

  • use model structs for the exact represenation in databse (maybe sometimes a field is not used in code, then its maybe fine to drop it off the struct e.g. Timestamp at Token tables)
  • use changesset struct based on model (wihout ids)
    • groups parametres for methods
    • allows validation on fields (ecto changeset, elm js data down actions up)
    • all fields are as they are on the model, all field must be supplied; no way for "partial updates"
  • partial updates for only one or two fields get a special method on the model
  • validate using garde and custom context with gives access to database pool

TODO: treat all selects with https://stackoverflow.com/questions/66728451/html-select-not-showing-selected-option-after-refresh-in-firefox