General Improvements#390
Conversation
| const entries = dbEntries.filter( | ||
| ({ category }: DBEntry) => categories === null || categories.indexOf(category) !== -1); | ||
|
|
||
| await Promise.all( |
There was a problem hiding this comment.
We can run requests in parallel.
|
|
||
| return res.sendStatus(200); | ||
| } No newline at end of file | ||
| return res.sendStatus(500); |
There was a problem hiding this comment.
The default status should not be 200, that should only happen when call succeeds.
There was a problem hiding this comment.
I think 500 should not be the default, use BadRequest 400 instead. 500 is better in the catch error. It also checks for the BadRequest so I think the current logic is fine.
There was a problem hiding this comment.
it's not actually default.
200 is only returned if try succeeds. Otherwise it's always 500 because we are not checking or limiting ourselves to a particular error type. That line can never be reached. I personally dislike returning from catch so it's just the existing logic, but structured differently.
There was a problem hiding this comment.
I see. Unlike you, I often return in catch.
| import { Service } from "../types/segments.model"; | ||
|
|
||
| export function getService<T extends string>(...value: T[]): Service { | ||
| const serviceByName = Object.values(Service).reduce((acc, serviceName) => { |
There was a problem hiding this comment.
By doing this we can achieve the same effect in O(n) instead of O(n^2)
|
Nice work! |
| const { | ||
| body: { | ||
| videoID, | ||
| userID, | ||
| categories, | ||
| service | ||
| } | ||
| } = req; |
Namaste Team 🙏🏽
First of all I'd like to thank you for the time this project has helped me saved while digesting YT content! As a payback I wanted to contribute to the project.
I just started understanding the basic structure and how things are being done in this project. I spotted some inefficiencies along the way and thought of creating a PR. In the future I plan on taking up active issues, but for now I just started dipping my toes 👣 and would like to understand the expectations from the owners.
In this PR, I introduced:
Thanks for your time!