internal/ and libs/ were both shared-code roots with no rule for which
one a package belonged in, so the split carried no information. Adopt a
rule the language answers by itself:
shared Go -> internal/
shared TypeScript -> libs/ (npm workspace packages)
libs/{ports,repo,server} move to internal/, leaving libs/ holding only
the two TypeScript packages (@jobs-scraper/rabbitmq-ts and
@jobs-scraper/browser-automation), which matches npm workspace
convention. internal/ is also Go's marker for code not importable from
outside the repo, which is accurate here since none of it is published.
Import paths are rewritten mechanically (jobs-scraper/libs/ ->
jobs-scraper/internal/) across 15 lines in 10 files. The 6 moved files
are pure renames with no content change. Doing this after the module
collapse in the previous commit meant no go.mod or replace-directive
edits were needed.
gofmt is applied to services/api/pkg/http/job.go, whose import group the
rewrite left out of order. Three files were already unformatted before
this refactor (internal/openai/interface.go, internal/ports/job-queries.go,
internal/repo/job-analysis-result.go) and are deliberately left alone to
keep this diff limited to the move.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
package job
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"log"
|
|
|
|
"github.com/jobs-scraper/internal/domain"
|
|
"github.com/jobs-scraper/internal/infrastructure/rabbitmq"
|
|
"github.com/jobs-scraper/internal/ports"
|
|
"github.com/jobs-scraper/internal/repo"
|
|
)
|
|
|
|
type CreateJob struct {
|
|
jobRepo *repo.JobRepository
|
|
rmq *rabbitmq.RabbitMQClient
|
|
}
|
|
|
|
func NewCreateJobHandler(jobRepo *repo.JobRepository, rmq *rabbitmq.RabbitMQClient) *CreateJob {
|
|
return &CreateJob{
|
|
jobRepo: jobRepo,
|
|
rmq: rmq,
|
|
}
|
|
}
|
|
|
|
func (cj *CreateJob) Handle(cmd ports.CreateJobCommand) error {
|
|
jobRequest := domain.SearchQuery{
|
|
Keywords: cmd.Keywords,
|
|
Location: cmd.Location,
|
|
FWT: cmd.FWT,
|
|
NumPages: cmd.NumPages,
|
|
}
|
|
|
|
jsonData, err := json.Marshal(jobRequest)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
switch cmd.Provider {
|
|
case domain.LinkedIn:
|
|
if err := cj.rmq.Publish(rabbitmq.LinkedInQueue, rabbitmq.ScraperExchange, jsonData); err != nil {
|
|
return err
|
|
}
|
|
log.Printf("Published LinkedIn job request: %s", string(jsonData))
|
|
case domain.Glassdoor:
|
|
if err := cj.rmq.Publish(rabbitmq.GlassDoorQueue, rabbitmq.ScraperExchange, jsonData); err != nil {
|
|
return err
|
|
}
|
|
log.Printf("Published Glassdoor job request: %s", string(jsonData))
|
|
default:
|
|
return errors.New("unsupported job provider")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// sk-24a0fbede3a8464b85e22360165a3cc9
|