api
api copied to clipboard
When collection settings specify a non-existent hook, documents endpoint silently fails
When a hook is specified in collection settings and there is no code for such a hook provided in the hooks directory, the collection's endpoint returns an empty response body.
This line is a good starting point for a solution.
Steps to replicate
Using the sample API config in the repo ⇒ collection reference
has
"hooks": {
"afterGet": ["check-reference"]
}
Accessing /vjoin/testdb/reference?compose=true&fields={}&filter={}&sort={"name":1}
(e.g. clicking on "reference" in the header in Publish) gives an empty response body, crashing Publish.
Expected behavior
Ideally, the API should throw an error on start. Less ideally, probably return a meaningful error object in the response.