add add user method

This commit is contained in:
2026-06-29 02:11:28 +07:00
parent 0f9bf8dfc1
commit 18fad25b27
5 changed files with 113 additions and 9 deletions
+14 -4
View File
@@ -3,13 +3,15 @@ package main
import (
"context"
_ "embed"
"evening_detective_server/internal/app"
"evening_detective_server/internal/repos/users_repo"
"evening_detective_server/internal/services/users_service"
proto "evening_detective_server/proto"
"log"
"net"
"net/http"
"os"
"evening_detective_server/internal/app"
proto "evening_detective_server/proto"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/joho/godotenv"
@@ -38,6 +40,9 @@ func main() {
log.Fatalf("QueryRow failed: %v\n", err)
}
usersRepo := users_repo.NewUserRepo(dbpool)
usersService := users_service.NewUsersService(usersRepo)
// Create a listener on TCP port
lis, err := net.Listen("tcp", ":8080")
if err != nil {
@@ -47,7 +52,12 @@ func main() {
// Create a gRPC server object
s := grpc.NewServer()
// Attach the Greeter service to the server
proto.RegisterEveningDetectiveServerServer(s, app.NewServer())
proto.RegisterEveningDetectiveServerServer(
s,
app.NewServer(
usersService,
),
)
// Serve gRPC server
log.Println("Serving gRPC on 0.0.0.0:8080")
go func() {