add Upload and Download files

This commit is contained in:
2026-07-12 18:05:52 +07:00
parent 2ecc6ecd6a
commit 487b1aa436
13 changed files with 854 additions and 63 deletions
+20 -5
View File
@@ -5,10 +5,12 @@ import (
_ "embed"
"evening_detective_server/internal/app"
"evening_detective_server/internal/modules/email_sender"
"evening_detective_server/internal/modules/file_storage"
"evening_detective_server/internal/modules/password_generator"
"evening_detective_server/internal/modules/processor_jwt"
"evening_detective_server/internal/repos/refresh_tokens_repo"
"evening_detective_server/internal/repos/users_repo"
"evening_detective_server/internal/services/file_service"
"evening_detective_server/internal/services/ui_service"
"evening_detective_server/internal/services/users_service"
proto "evening_detective_server/proto"
@@ -47,15 +49,26 @@ func main() {
usersRepo := users_repo.NewUserRepo(dbpool)
passwordGenerator := password_generator.NewGenerator(8)
smtpHost := os.Getenv("SMTP_HOST")
smtpPort := os.Getenv("SMTP_PORT")
smtpUser := os.Getenv("SMTP_USER")
smtpPassword := os.Getenv("SMTP_PASSWORD")
emailSender := email_sender.NewSender(smtpHost, smtpPort, smtpUser, smtpPassword)
emailSender := email_sender.NewSender(
os.Getenv("SMTP_HOST"),
os.Getenv("SMTP_PORT"),
os.Getenv("SMTP_USER"),
os.Getenv("SMTP_PASSWORD"),
)
processorJWT := processor_jwt.NewProcessor(os.Getenv("JWT_SECRET"))
refreshTokensRepo := refresh_tokens_repo.NewRefreshTokensRepo(dbpool)
usersService := users_service.NewUsersService(usersRepo, passwordGenerator, emailSender, processorJWT, refreshTokensRepo)
uiService := ui_service.NewUiService()
fileStorage, err := file_storage.NewRustFSStorage(
os.Getenv("S3_HOST"),
os.Getenv("S3_USER"),
os.Getenv("S3_PASSWORD"),
os.Getenv("S3_BUCKET"),
)
if err != nil {
log.Fatalf("Unable to create connection rustfs: %v\n", err)
}
fileService := file_service.NewFileService(fileStorage)
// Create a listener on TCP port
lis, err := net.Listen("tcp", ":8080")
@@ -74,6 +87,7 @@ func main() {
"/crabs.evening_detective_server.EveningDetectiveServer/RefreshPassword": true,
"/crabs.evening_detective_server.EveningDetectiveServer/Login": true,
"/crabs.evening_detective_server.EveningDetectiveServer/Refresh": true,
"/crabs.evening_detective_server.EveningDetectiveServer/DownloadFile": true,
},
processorJWT,
),
@@ -85,6 +99,7 @@ func main() {
app.NewServer(
usersService,
uiService,
fileService,
),
)
// Serve gRPC server