-
Notifications
You must be signed in to change notification settings - Fork 1
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
64 backend refining database connection #112
64 backend refining database connection #112
Conversation
…kend-refining-database-connection
…kend-refining-database-connection
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 🍡
Server/src/routes/poitype.route.ts
Outdated
@@ -84,7 +84,7 @@ export class PoiTypeRoute { | |||
private async createType(req: Request, res: Response): Promise<void> { | |||
const { name, icon, description }: CreatePOIType = req.body | |||
|
|||
const poiType: POIType | null = await database.pois.saveType(name, icon, description) | |||
const poiType: POIType | null = await database.pois.saveType({ name, icon, description }) |
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.
Can't we use the casted request body and pass it directly to the saveType
function?
Maybe something like this?
const poiTypeInput: CreatePOIType = req.body
const poiType: POIType | null = await database.pois.saveType(poiTypeInput)
Or do we have to use the Prisma.POITypeCreateInput
type and this is a magical case where both types line up?
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.
I just double checked this: It is indeed possible!
In my first iteration for this branch I just changed the database calls in the routes and services so that the methods are still working like intended but we can change it here to parse the poiTypeInput
directly
"Ask a programmer to review 10 lines of code and they will find 10 issues, ask them to review 500 lines of code and they will say it looks good." This PR is 1000 LoC. |
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.
Resolve conflicts and merge (see comment).
…kend-refining-database-connection
I deleted the try-catch-blocks for better exception handeling on API side, defined cascading delete for POIs if the Track gets deleted and introduced object deconstruction for database calls for maintainablity.
The latter was also executed for routes and services and I solved the corresponding merge conflicts. (Up to date with development)
I tested the whole thing on my system multiple times and couldn't find any new bug corresponding to my changes. But please feel free to test it on your side!
If the PR is good to go the branch can be discarded.