Skip to content
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

Merged
merged 22 commits into from
Sep 5, 2023

Conversation

Niatsuna
Copy link
Contributor

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.

@Niatsuna Niatsuna added enhancement New feature or request backend labels Aug 31, 2023
@Niatsuna Niatsuna linked an issue Aug 31, 2023 that may be closed by this pull request
6 tasks
@Niatsuna Niatsuna changed the base branch from main to development August 31, 2023 14:14
Copy link
Contributor

@JulianGrabitzky JulianGrabitzky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 🍡

@@ -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 })
Copy link
Contributor

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?

Copy link
Contributor Author

@Niatsuna Niatsuna Sep 4, 2023

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

@NicoBiernat
Copy link
Contributor

"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.
But we had this discussion already.
I fixed some eslint errors including formatting, unused imports and using "const" instead of "let" whereever possible.
Other than that I would say: Merge it after resolving all conflicts and then we'll see if something breaks.

Copy link
Contributor

@NicoBiernat NicoBiernat left a 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).

@Niatsuna Niatsuna merged commit 237748f into development Sep 5, 2023
1 check passed
@Niatsuna Niatsuna deleted the 64-backend-refining-database-connection branch September 5, 2023 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Backend] Refining Database Connection
3 participants