Refactor js_generic
to use common DynamicJSEndpointRegistry
hierarchy, and expose as an extensible public header
#6710
+197
−925
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #6682.
We copied a bunch of functionality from
js_generic
toDynamicJSEndpointRegistry
, so that the latter could be extended by apps to run their own JS endpoints. Eventually we wanted near-identical functionality, so these implementations have a lot of duplication. This merges the 2, deleting the standalonejs_generic
code and making it instead extend theDynamicJSEndpointRegistry
hierarchy. By using its own (not-quite-just-a-common-prefix) table names, and pushing some missing functionality up the stack intoDynamicJSEndpointRegistry
, we get to delete a load of code and get back to functional parity.The commits in this PR show slightly cleaner steps than the final diff, but the key changes are:
DynamicJSEndpointRegistry
splits out aBaseDynamicJSEndpointRegistry
base class, which is everything-but-the-audit functions/members. The newjs_generic
subclassesBase...
, to confirm it doesn't use/want the audit/record functions. Everyone else extendsDynamicJSEndpointRegistry
and sees no change. (This one is technically unnecessary, but I did it anyway)BaseDynamicJSEndpointRegistry
now does 2 more things thatjs_generic
was doing, and it wasn't (beautifully,js_generic
built and mostly ran succesfully after deleting all of its code and changing its base class, and then a few e2e tests picked up these behavioural discrepancies):log_execution_metrics
option. I think this will be expected for some deployments directly replacingjs_generic
with app-space JS, but we may want to add some other controls for turning it on/off.get_allowed_verbs
so that HTTPOPTIONS
requests (and maybe some other requests?) accurately describe the valid verbs for a given path, even when they're JS, rather than just a generic 404.js_generic
is exposed in a public header, as a sample registry which could be extended with your ownjs::Extensions
. CalledGovernanceDrivenJSRegistry
, because nithtwd.