package server import ( "fmt" "os" "git.ctrlz.es/mgdelacroix/birthdaybot/model" "git.ctrlz.es/mgdelacroix/birthdaybot/parser" "github.com/charmbracelet/log" ) type Server struct { logger *log.Logger config *model.Config birthdays []*model.Birthday } func New(config *model.Config) (*Server, error) { logger := log.New(os.Stderr) logger.Info("Parsing CSV file", "birthdayFile", config.BirthdayFile) birthdays, err := parser.ParseCSV(config.BirthdayFile) if err != nil { logger.Error("cannot parse CSV file", "birthdayFile", config.BirthdayFile, "error", err) return nil, fmt.Errorf("cannot parse CSV file %s: %w", config.BirthdayFile, err) } logger.Info("creating server") server := &Server{ logger: logger, config: config, birthdays: birthdays, } return server, nil }