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

Fixed fiber context error #16

Merged
merged 5 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions backend/cmd/login/login.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package main

import (
"context"
"flag"
"fmt"
"log"
"net"
"strings"

"github.com/GenerateNU/nightlife/internal/config"
"github.com/nedpals/supabase-go"
)

func main() {

ips, err := net.LookupIP("nydgnuqtgjljprotsccz.supabase.co")
if err != nil {
fmt.Printf("Failed to resolve hostname: %v\n", err)
} else {
fmt.Printf("Supabase IPs: %v\n", ips)
}

cfg, err := config.LoadConfig("../../../.env")

if err != nil {
log.Fatalf("Environment variables could not be loaded")
}

fmt.Printf("Supabase URL: %s\n", cfg.SupabaseURL)
fmt.Printf("Supabase Key: %s\n", cfg.SupabaseKey)

flag.Parse()

args := flag.Args()
if len(args) < 2 || args[0] == "" || args[1] == "" {
fmt.Println(len(args))
log.Fatalf("include command line arguments correctly: \n %s", strings.Join(args, ""))
}

email := args[0]
password := args[1]

client := supabase.CreateClient(cfg.SupabaseURL, cfg.SupabaseKey)

details, err := client.Auth.SignIn(context.Background(), supabase.UserCredentials{
Email: email,
Password: password,
Data: nil,
})

if err != nil {
fmt.Println(err)
log.Fatalf("Sign in failed")
}

fmt.Printf("Access Token: %s", details.AccessToken)

}
9 changes: 2 additions & 7 deletions backend/cmd/server/main.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package main

import (
"log"

"github.com/GenerateNU/nightlife/internal/auth"
"github.com/GenerateNU/nightlife/internal/config"
"github.com/GenerateNU/nightlife/internal/db"
"github.com/GenerateNU/nightlife/internal/middleware"
"github.com/GenerateNU/nightlife/internal/router"
"github.com/gofiber/fiber/v2"
"log"
)

func main() {
Expand All @@ -28,14 +26,11 @@ func main() {
//Create App
app := fiber.New()

//Configure authentication service
auth.ConfigureAuth(cfg)

//Initialize Middleware
middleware.UseMiddleware(app)

// Hello Group
router.InitializeRoutes(app)
router.InitializeRoutes(app, cfg)

//Run app
log.Fatal(app.Listen(":8080"))
Expand Down
71 changes: 39 additions & 32 deletions backend/go.mod
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
module github.com/GenerateNU/nightlife

go 1.21.6

require (
github.com/gofiber/fiber/v2 v2.52.5
github.com/jackc/pgx/v4 v4.18.3
github.com/joho/godotenv v1.5.1
)

require (
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.14.3 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.3.3 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgtype v1.14.0 // indirect
github.com/klauspost/compress v1.17.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.51.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
golang.org/x/crypto v0.20.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
)
module github.com/GenerateNU/nightlife

go 1.21.6

require (
github.com/gofiber/fiber/v2 v2.52.5
github.com/jackc/pgx/v4 v4.18.3
github.com/joho/godotenv v1.5.1
)

require (
github.com/google/go-querystring v1.1.0 // indirect
github.com/nedpals/postgrest-go v0.1.3 // indirect
)

require (
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/google/uuid v1.5.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.14.3 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.3.3 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgtype v1.14.0 // indirect
github.com/klauspost/compress v1.17.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/nedpals/supabase-go v0.4.0
github.com/rivo/uniseg v0.2.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.51.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
golang.org/x/crypto v0.20.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
)
Loading
Loading