Page MenuHomePhabricator

[keyserver] Move validators to endpoint array
ClosedPublic

Authored by michal on Jul 28 2023, 11:53 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jun 29, 12:55 AM
Unknown Object (File)
Thu, Jun 27, 7:36 PM
Unknown Object (File)
Thu, Jun 27, 4:40 AM
Unknown Object (File)
Wed, Jun 26, 9:37 AM
Unknown Object (File)
Mon, Jun 24, 8:50 PM
Unknown Object (File)
Wed, Jun 12, 9:17 PM
Unknown Object (File)
Tue, Jun 11, 9:14 PM
Unknown Object (File)
Fri, Jun 7, 2:05 AM
Subscribers

Details

Summary

(ENG-3879)[https://linear.app/comm/issue/ENG-3879/move-output-and-input-validators-outside-of-the-responders]

Followup to the id schema work. Moving all the validation to the endpoint array makes it less likely for the devs to forgot to add it (which already happened a few times). Additionaly it moves the validation logic outside of the responder and now they are fully focused on the business logic.

An additional change that needed to be made was exporting the input validators, so they could be imported in the endpoints.js.

I choose to not split it into multiple diffs, because I'm doing the same thing everywhere, but if it's hard to review I can split into more diffs.

Test Plan
  • run yarn flow-all (note: for some reason flow allows wrong output responders, even they are correctly typed with generics)
  • play around the app and check if everything works correctly (in particular I tested log in, register and siwe flows)

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

keyserver/src/responders/handlers.js
39 ↗(On Diff #29192)

Note that I've made this type opaque which basically means that it can't be created outside of this file, which is an additional safeguard against not including validators. But if it's overkill I can remove it.

keyserver/src/responders/responder-validators.test.js
4 ↗(On Diff #29192)

The name was changed to better match the our conventions

lib/types/request-types.js
301–306 ↗(On Diff #29192)

This wasn't validated previously, so I added this validator (the endpoint didn't return any ids so it was fine, but we should validate all responders for consistency)

Haven't reviewed all the changes too closely - there are a lot of them and they are really similar. All the important changes look good and the overall idea is great!

This revision is now accepted and ready to land.Jul 31 2023, 4:50 AM