diff --git a/adapters/dolar/dolar.go b/adapters/dolar/dolar.go index a16a7c7..af82f17 100644 --- a/adapters/dolar/dolar.go +++ b/adapters/dolar/dolar.go @@ -4,8 +4,8 @@ import ( "context" "time" - "github.com/maximotejeda/msvc-proto/golang/dolar" - "github.com/maximotejeda/us_dop_api/domain" + "git.maximotejeda.com/maximo/dolar/proto/golang/dolar" + "git.maximotejeda.com/maximo/us-dop-api/domain" "google.golang.org/grpc" ) diff --git a/cmd/api/main.go b/cmd/api/main.go index cfd60ed..7c6718b 100644 --- a/cmd/api/main.go +++ b/cmd/api/main.go @@ -8,12 +8,12 @@ import ( "os" "path/filepath" - "github.com/maximotejeda/us_dop_api/adapters/dolar" - "github.com/maximotejeda/us_dop_api/handlers" - "github.com/maximotejeda/us_dop_api/middlewares" - "github.com/maximotejeda/us_dop_api/static" - "github.com/maximotejeda/us_dop_bot/config" - "github.com/maximotejeda/us_dop_db/db" + "git.maximotejeda.com/maximo/us-dop-api/adapters/dolar" + "git.maximotejeda.com/maximo/us-dop-api/config" + "git.maximotejeda.com/maximo/us-dop-api/handlers" + "git.maximotejeda.com/maximo/us-dop-api/middlewares" + "git.maximotejeda.com/maximo/us-dop-api/static" + "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" ) @@ -31,7 +31,7 @@ func main() { var opts []grpc.DialOption opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials())) - dolarConn, err := grpc.Dial(config.GetDollarServiceURL(), opts...) + dolarConn, err := grpc.NewClient(config.GetDollarServiceURL(), opts...) if err != nil { log.Error("creating gerpc conn", "error", err) panic(err) @@ -60,10 +60,9 @@ func main() { } // init database - dbe := db.Dial("dolardb/crawler.db", log) // handler containing all the necessary files - root := handlers.NewRoot(dbe, dol, log, toParseFiles) + root := handlers.NewRoot( dol, log, toParseFiles) s := middlewares.NewLogger(http.HandlerFunc(static.ServeFiles), log) r := middlewares.NewLogger(root, log) diff --git a/go.mod b/go.mod index 1986eda..c1c4815 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/maximotejeda/us_dop_api +module git.maximotejeda.com/maximo/us-dop-api go 1.22.0 diff --git a/handlers/api/api.go b/handlers/api/api.go index f44b619..e9eb331 100644 --- a/handlers/api/api.go +++ b/handlers/api/api.go @@ -6,14 +6,13 @@ import ( "net/http" "time" - "github.com/maximotejeda/us_dop_api/domain" - "github.com/maximotejeda/us_dop_api/ports" - "github.com/maximotejeda/us_dop_db/db" + "git.maximotejeda.com/maximo/us-dop-api/domain" + "git.maximotejeda.com/maximo/us-dop-api/ports" + ) type API struct { http.ServeMux - db *db.DB dolar ports.DolarService log *slog.Logger templ template.Template @@ -27,10 +26,9 @@ type SearchResult struct { Results []*domain.History `josn:"results"` } -func NewApiHandler(db *db.DB, dolar ports.DolarService, log *slog.Logger, templ template.Template) *API { +func NewApiHandler( dolar ports.DolarService, log *slog.Logger, templ template.Template) *API { log = log.With("api", "insti") api := &API{ - db: db, log: log, dolar: dolar, templ: templ, diff --git a/handlers/api/institution.go b/handlers/api/institution.go index 2185782..a8f1e49 100644 --- a/handlers/api/institution.go +++ b/handlers/api/institution.go @@ -9,8 +9,8 @@ import ( "strings" "time" - "github.com/maximotejeda/us_dop_api/domain" - "github.com/maximotejeda/us_dop_api/helpers" + "git.maximotejeda.com/maximo/us-dop-api/domain" + "git.maximotejeda.com/maximo/us-dop-api/helpers" ) // handler to parse query to the api diff --git a/handlers/handlers.go b/handlers/handlers.go index f5ecee2..a022544 100644 --- a/handlers/handlers.go +++ b/handlers/handlers.go @@ -7,9 +7,8 @@ import ( "strings" "time" - "github.com/maximotejeda/us_dop_api/handlers/api" - "github.com/maximotejeda/us_dop_api/ports" - "github.com/maximotejeda/us_dop_db/db" + "git.maximotejeda.com/maximo/us-dop-api/handlers/api" + "git.maximotejeda.com/maximo/us-dop-api/ports" ) var ( @@ -19,13 +18,12 @@ var ( // Mux will mix and match all sub routes type Root struct { http.ServeMux - db *db.DB log *slog.Logger dolar ports.DolarService templates *template.Template } -func NewRoot(dbe *db.DB, dolar ports.DolarService, log *slog.Logger, files []string) *Root { +func NewRoot(dolar ports.DolarService, log *slog.Logger, files []string) *Root { funcMap := template.FuncMap{ "add": add[float64], "div": div, @@ -44,7 +42,7 @@ func NewRoot(dbe *db.DB, dolar ports.DolarService, log *slog.Logger, files []str templ.ExecuteTemplate(w, "index", nil) //w.Write([]byte("{'status': 'ok'}")) }) - inst := api.NewApiHandler(dbe, dolar, log, templ) + inst := api.NewApiHandler( dolar, log, templ) r.Handle("GET /api/{inst}/", inst) r.Handle("POST /api/instituciones/history", inst) r.Handle("GET /api/latest/{inst}", inst) diff --git a/ports/dolar.go b/ports/dolar.go index 18c78fc..f52cbff 100644 --- a/ports/dolar.go +++ b/ports/dolar.go @@ -1,6 +1,6 @@ package ports -import "github.com/maximotejeda/us_dop_api/domain" +import "git.maximotejeda.com/maximo/us-dop-api/domain" type DolarService interface { GetLatest(name string) (*domain.History, error)