40 lines
1 KiB
Go
40 lines
1 KiB
Go
package app
|
|
|
|
import (
|
|
"database/sql"
|
|
|
|
"github.com/gorilla/mux"
|
|
"github.com/jobs-scraper/internal/infrastructure/rabbitmq"
|
|
"github.com/jobs-scraper/libs/ports"
|
|
"github.com/jobs-scraper/libs/repo"
|
|
"github.com/jobs-scraper/libs/server"
|
|
jobCommands "github.com/jobs-scraper/services/api/internal/commands/job"
|
|
jobQueries "github.com/jobs-scraper/services/api/internal/queries/job"
|
|
)
|
|
|
|
type Application struct {
|
|
Router *mux.Router
|
|
DB *sql.DB
|
|
Server *server.AppServer
|
|
JobCommands *ports.JobCommands
|
|
JobQueries *ports.JobQueries
|
|
}
|
|
|
|
func NewApplication(router *mux.Router, db *sql.DB, rmq *rabbitmq.RabbitMQClient) *Application {
|
|
s := server.NewServer(router)
|
|
|
|
jobRepo := repo.NewJobRepository(db)
|
|
|
|
return &Application{
|
|
Server: s,
|
|
Router: router,
|
|
DB: db,
|
|
JobCommands: &ports.JobCommands{
|
|
CreateJob: jobCommands.NewCreateJobHandler(jobRepo, rmq),
|
|
ApplyForJob: jobCommands.NewApplyForJobHandler(jobRepo, rmq),
|
|
},
|
|
JobQueries: &ports.JobQueries{
|
|
GetJobs: jobQueries.NewGetJobsHandler(jobRepo),
|
|
},
|
|
}
|
|
}
|