verida / data-connector-server

1 stars 2 forks source link

Consider splitting Controller and Service #110

Open aurelticot opened 1 month ago

aurelticot commented 1 month ago

All the API handling is currently implemented in a Controller class.

Consider splitting in two:

Main reasons for this ticket is because of the discrepancies in the Controller function to handle the request and the response.

There are many cases where the endpoints are not validating the params, explicitely accept them as undefined even if required, continue with the logic which eventually fails and catch the error to return a 500 even though a 400 Bad Request could have been returned earlier (or a 401 Unauthorized if the key - or whatever the auth - is missing).

Look at The Verida Missions API for the structure: