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

refactor! #20

Merged
merged 5 commits into from
Sep 24, 2024
Merged

refactor! #20

merged 5 commits into from
Sep 24, 2024

Conversation

wyattchris
Copy link
Collaborator

Description

[Link to Ticket](insert the link to your ticket inside the parenthesis here)

Please include a summary of the changes and the related issue. Please also
include relevant motivation, context, and images!

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. If they are unit
tests, provide the file name the tests are in. If they are not unit tests,
describe how you tested the change.

Checklist

  • I have performed a self-review of my code
  • I have reached out to another developer to review my code
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes

backend/internal/db/db.go Outdated Show resolved Hide resolved
@@ -22,7 +23,11 @@ func RouteHelloGroup(app *fiber.App, config *config.Config) {
unprotected := app.Group("/hello")

//Endpoints
protected.Get("/world", hello.RetHelloWorld)
unprotected.Get("/world", hello.RetHelloWorld)
protected.Get("/world", func(c *fiber.Ctx) error {
Copy link
Member

Choose a reason for hiding this comment

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

if you create a struct with the db as a field, you can simplify this.
struct example
register route example

)

func RetHelloWorld(ctx *fiber.Ctx) error {
func RetHelloWorld(ctx *fiber.Ctx, db *pgx.Conn) error {
Copy link
Member

@garrettladley garrettladley Sep 23, 2024

Choose a reason for hiding this comment

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

by doing the struct field approach, you will resolve this error. also, is this really a "transaction"? i would consider this a handler.

@garrettladley garrettladley changed the title Pass database down to backend routes (example)! refactor! Sep 24, 2024
Copy link
Member

@garrettladley garrettladley left a comment

Choose a reason for hiding this comment

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

LGTM

@garrettladley garrettladley merged commit 7bab3e2 into main Sep 24, 2024
3 checks passed
abyan-n pushed a commit that referenced this pull request Sep 24, 2024
* pass databse down to backend routes

* fix db error return

* Co-authored-by: Garrett Ladley <[email protected]>

* Co-authored-by: Garrett Ladley <[email protected]>

* lint fxes
abyan-n pushed a commit that referenced this pull request Sep 25, 2024
* pass databse down to backend routes

* fix db error return

* Co-authored-by: Garrett Ladley <[email protected]>

* Co-authored-by: Garrett Ladley <[email protected]>

* lint fxes
@garrettladley garrettladley deleted the feature/db-example branch September 30, 2024 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants