Skip to content

Commit

Permalink
chore: change channel code
Browse files Browse the repository at this point in the history
  • Loading branch information
Caknoooo committed Jul 11, 2024
1 parent 8b346b8 commit bfc4f91
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ DB_PORT = 5432

NGINX_PORT=8080
GOLANG_PORT=8888
APP_ENV=localhost

SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_SENDER_NAME="Go.Gin.Template <[email protected]>"
SMTP_AUTH_EMAIL=[email protected]
SMTP_AUTH_PASSWORD=idrqtymakoopjqwy
SMTP_AUTH_EMAIL=<your email>
SMTP_AUTH_PASSWORD=<your password>
16 changes: 15 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,15 @@ func main() {
var (
db *gorm.DB = config.SetUpDatabaseConnection()
jwtService service.JWTService = service.NewJWTService()

// Implementation Dependency Injection
// Repository
userRepository repository.UserRepository = repository.NewUserRepository(db)

// Service
userService service.UserService = service.NewUserService(userRepository, jwtService)

// Controller
userController controller.UserController = controller.NewUserController(userService)
)

Expand All @@ -33,6 +40,7 @@ func main() {
routes.User(server, userController, jwtService)

var wg sync.WaitGroup
var serve string
wg.Add(2)

go func() {
Expand All @@ -58,7 +66,13 @@ func main() {
port = "8888"
}

if err := server.Run("localhost:" + port); err != nil {
if os.Getenv("APP_ENV") == "localhost" {
serve = "127.0.0.1:" + port
} else {
serve = ":" + port
}

if err := server.Run(serve); err != nil {
log.Fatalf("error running server: %v", err)
}
}

0 comments on commit bfc4f91

Please sign in to comment.