-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: migrate get encrypt metadata endpoint controller to TypeScript #711
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 question
): ResultAsync<SubmissionMetadata | null, DatabaseError> => { | ||
// Early return, do not even retrieve from database. | ||
if (!mongoose.Types.ObjectId.isValid(submissionId)) { | ||
return okAsync(null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we actually want to return 200 with an empty list if the submission ID in the query parameter is invalid? isn't that more of a 400?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is due to frontend sending possible invalid submissionIds due to search, and if we return 400 an error is shown to the user resulting in confusion.
returning nothing means no result found, but it's still a valid search term i guess.
We can change it if you want, just not in this PR.
Related issue opened for the debounce thingy: #603
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok sounds good
Problem
Building upon #601, this PR migrates the rest of the controller into Typescript.
Solution
Features:
EncryptSubSvc#getSubmissionMetadata
service fn to use model static methodEncryptSubSvc#getSubmissionMetadataList
service fn to use model static methodEncryptSubCtl#handleGetMetadata
handler fn for route endpointImprovements:
query.page
is now optional iffquery.submissionId
exists, since singular submission metadata search does not require the page parameter.Tests
Add tests for all new methods.
Note that route integration tests are not done in this PR, and will be done when route also gets refactored.