Files
nunu-layout-advanced/cmd/server/wire/wire.go
T

62 lines
1.3 KiB
Go

//go:build wireinject
// +build wireinject
package wire
import (
"github.com/go-nunu/nunu-layout-advanced/internal/handler"
"github.com/go-nunu/nunu-layout-advanced/internal/repository"
"github.com/go-nunu/nunu-layout-advanced/internal/server"
"github.com/go-nunu/nunu-layout-advanced/internal/service"
"github.com/go-nunu/nunu-layout-advanced/pkg/app"
"github.com/go-nunu/nunu-layout-advanced/pkg/helper/sid"
"github.com/go-nunu/nunu-layout-advanced/pkg/jwt"
"github.com/go-nunu/nunu-layout-advanced/pkg/log"
"github.com/go-nunu/nunu-layout-advanced/pkg/server/http"
"github.com/google/wire"
"github.com/spf13/viper"
)
var handlerSet = wire.NewSet(
handler.NewHandler,
handler.NewUserHandler,
)
var serviceSet = wire.NewSet(
service.NewService,
service.NewUserService,
)
var repositorySet = wire.NewSet(
repository.NewDB,
repository.NewRedis,
repository.NewRepository,
repository.NewUserRepository,
)
var serverSet = wire.NewSet(
server.NewHTTPServer,
server.NewJob,
server.NewTask,
)
// build App
func newApp(httpServer *http.Server, job *server.Job) *app.App {
return app.NewApp(
app.WithServer(httpServer, job),
app.WithName("demo-server"),
)
}
func NewWire(*viper.Viper, *log.Logger) (*app.App, func(), error) {
panic(wire.Build(
repositorySet,
serviceSet,
handlerSet,
serverSet,
sid.NewSid,
jwt.NewJwt,
newApp,
))
}