Skip to content

Commit

Permalink
vingo: put things behind api route
Browse files Browse the repository at this point in the history
  • Loading branch information
hannes-dev committed Aug 12, 2024
1 parent e1c2232 commit e19d146
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions vingo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,23 @@ func main() {
db := database.Get()
defer db.Close()

public := fiber.New(fiber.Config{})
api := fiber.New(fiber.Config{})

public.Use(cors.New(cors.Config{
api.Use(cors.New(cors.Config{
AllowOrigins: corsAllowOrigins,
AllowHeaders: "Origin, Content-Type, Accept, Access-Control-Allow-Origin",
AllowCredentials: true,
}))

// Public routes
public.Post("/login", handlers.Login)
public.Get("/auth/callback", handlers.Callback)
{
api.Post("/login", handlers.Login)
api.Get("/auth/callback", handlers.Callback)

public.Post("/scans", handlers.ScanRegister)
api.Post("/scans", handlers.ScanRegister)

public.Get("/recent_scans", handlers.PublicRecentScans)
api.Get("/recent_scans", handlers.PublicRecentScans)

api := public.Group("/api", handlers.IsLoggedIn)
{
api.Post("/logout", handlers.Logout)
api.Get("/user", handlers.User)
api.Get("/leaderboard", handlers.Leaderboard)
Expand All @@ -64,7 +63,7 @@ func main() {
}
}

log.Println(public.Listen(":4000"))
log.Println(api.Listen(":4000"))
}

func setupFromEnv() {
Expand Down

0 comments on commit e19d146

Please sign in to comment.