package main

import (
	"log/slog"

	"git.maximotejeda.com/maximo/tgb-user/config"
	"git.maximotejeda.com/maximo/tgb-user/internal/adapters/db"
	"git.maximotejeda.com/maximo/tgb-user/internal/adapters/grpc"
	"git.maximotejeda.com/maximo/tgb-user/internal/application/core/api"
)

func main() {
	log := slog.Default()
	log.With("place", "main")
	dbAdapter, err := db.NewAdapter(config.GetDataSourceURL())
	if err != nil {
		log.Error("creating db connection", "error", err)
	}
	app := api.NewApplication(dbAdapter)

	grpcAdapter := grpc.NewAdapter(app, config.GetApplicationPort())
	log.Info("[tgbuser] service running", "port", config.GetApplicationPort())
	grpcAdapter.Run()
}
