-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
119 changed files
with
7,305 additions
and
7,280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[linters] | ||
enable = ["revive", "errcheck"] | ||
[linters] | ||
enable = ["revive", "errcheck"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package bookmarks | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/GenerateNU/nightlife/internal/errs" | ||
"github.com/GenerateNU/nightlife/internal/models" | ||
"github.com/gofiber/fiber/v2" | ||
"github.com/google/uuid" | ||
) | ||
|
||
func (s *Service) GetBookmarkFromID(c *fiber.Ctx) error { | ||
fmt.Println("Pinging correct service") | ||
|
||
userID := c.Params("userId") | ||
fmt.Println("----", userID) | ||
if userID == "" { | ||
c.Status(http.StatusBadRequest) | ||
return fiber.NewError(400) | ||
} | ||
UserIDFormatted, err := uuid.Parse(userID) | ||
|
||
if err != nil { | ||
c.Status(http.StatusBadRequest) | ||
return fiber.NewError(400, "Malformed User ID") | ||
} | ||
|
||
Bookmarks, err := s.store.GetBookmarkFromID(c.Context(), UserIDFormatted) | ||
|
||
if err != nil { | ||
fmt.Println("Error is on service line 26" + err.Error()) | ||
c.Status(http.StatusInternalServerError) | ||
return err | ||
} | ||
|
||
return c.Status(http.StatusOK).JSON(Bookmarks) | ||
|
||
} | ||
|
||
func (s *Service) CreateBookmark(c *fiber.Ctx) error { | ||
var p models.Bookmarks | ||
fmt.Println("****") | ||
if err := c.BodyParser(&p); err != nil { | ||
fmt.Println("HERE") | ||
return errs.BadRequest(err) | ||
} | ||
|
||
if err := s.store.CreateBookmark(c.Context(), p); err != nil { | ||
fmt.Println("error: ", err.Error()) | ||
return err | ||
} | ||
|
||
// close out with success status | ||
return c.Status(fiber.StatusCreated).JSON(p) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package bookmarks | ||
|
||
import ( | ||
"github.com/GenerateNU/nightlife/internal/types" | ||
"github.com/gofiber/fiber/v2" | ||
) | ||
|
||
// Create HelloGroup fiber route group | ||
func Routes(app *fiber.App, params types.Params) { | ||
service := newService(params.Store) | ||
|
||
// Create Protected Grouping | ||
protected := app.Group("/bookmarks") | ||
|
||
// Register Middleware | ||
// protected.Use(auth.Protected(¶ms.Supabase)) | ||
|
||
//Endpoints | ||
protected.Get("/:userId", service.GetBookmarkFromID) | ||
protected.Post("/:venueId/:userId", service.CreateBookmark) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package bookmarks | ||
|
||
import "github.com/GenerateNU/nightlife/internal/storage" | ||
|
||
type Service struct { | ||
store storage.Storage | ||
} | ||
|
||
func newService(store storage.Storage) *Service { | ||
return &Service{store: store} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package event | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/GenerateNU/nightlife/internal/errs" | ||
"github.com/gofiber/fiber/v2" | ||
"github.com/google/uuid" | ||
) | ||
|
||
func (s *Service) GetEventForVenue(c *fiber.Ctx) error { | ||
|
||
venueID := c.Params("venue_id") | ||
|
||
if venueID == "" { | ||
c.Status(http.StatusBadRequest) | ||
return errs.APIError{StatusCode: fiber.StatusBadRequest, Message: "username is required"} | ||
} | ||
|
||
VenueIDFormatted, err := uuid.Parse(venueID) | ||
|
||
if err != nil { | ||
c.Status(http.StatusInternalServerError) | ||
return errs.APIError{StatusCode: fiber.StatusNotFound, Message: "profile not found"} | ||
} | ||
|
||
VenueEvents, err := s.store.GetEventForVenue(c.Context(), VenueIDFormatted) | ||
|
||
if err != nil { | ||
c.Status(http.StatusInternalServerError) | ||
return err | ||
} | ||
|
||
return c.Status(http.StatusOK).JSON(VenueEvents) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package event | ||
|
||
import ( | ||
"github.com/GenerateNU/nightlife/internal/types" | ||
"github.com/gofiber/fiber/v2" | ||
) | ||
|
||
// Create Event fiber route group | ||
func Routes(app *fiber.App, params types.Params) { | ||
service := newService(params.Store) | ||
|
||
// Create Protected Grouping | ||
protected := app.Group("/event") | ||
|
||
// Register Middleware | ||
//protected.Use(auth.Protected(¶ms.Supabase)) | ||
|
||
//Endpoints | ||
protected.Get("/:venue_id", service.GetEventForVenue) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package event | ||
|
||
import "github.com/GenerateNU/nightlife/internal/storage" | ||
|
||
type Service struct { | ||
store storage.Storage | ||
} | ||
|
||
func newService(store storage.Storage) *Service { | ||
return &Service{store: store} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,17 @@ | ||
package friendship | ||
|
||
import ( | ||
//"github.com/GenerateNU/nightlife/internal/auth" | ||
"github.com/GenerateNU/nightlife/internal/types" | ||
"github.com/gofiber/fiber/v2" | ||
) | ||
|
||
func Routes(app *fiber.App, params types.Params) { | ||
|
||
//create a service | ||
service := newService(params.Store) | ||
|
||
//create a grouping | ||
protected := app.Group("/friendships") | ||
//.Use(auth.Protected(¶ms.Supabase)) | ||
|
||
//create a route | ||
protected.Post("/api/friendship", service.CreateFriendship) | ||
protected.Post("/", service.CreateFriendship) | ||
protected.Get("/:userID", service.GetFriendshipsByUserID) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.