diff --git a/comicverse.go b/comicverse.go index 72bd40d..eada92e 100644 --- a/comicverse.go +++ b/comicverse.go @@ -115,6 +115,8 @@ func (app *app) setup() error { DB: app.db, S3: app.s3, + Context: app.ctx, + Assertions: app.assert, Logger: app.logger, }) diff --git a/service/service.go b/service/service.go index cbc599d..eb33b6d 100644 --- a/service/service.go +++ b/service/service.go @@ -1,6 +1,7 @@ package service import ( + "context" "database/sql" "errors" "log/slog" @@ -13,6 +14,8 @@ type service struct { db *sql.DB s3 *s3.Client + ctx context.Context + assert tinyssert.Assertions log *slog.Logger } @@ -22,7 +25,10 @@ func New(cfg Config) (Service, error) { return nil, errors.New("database should not be a nil interface") } if cfg.S3 == nil { - return nil, errors.New("s3 client should not be a nil interface") + return nil, errors.New("s3 client should not be a nil pointer") + } + if cfg.Context == nil { + return nil, errors.New("context should not be a nil interface") } if cfg.Assertions == nil { return nil, errors.New("assertions should not be a nil interface") @@ -33,6 +39,8 @@ func New(cfg Config) (Service, error) { return &service{ db: cfg.DB, + ctx: cfg.Context, + assert: cfg.Assertions, log: cfg.Logger, }, nil @@ -42,6 +50,8 @@ type Config struct { DB *sql.DB S3 *s3.Client + Context context.Context + Assertions tinyssert.Assertions Logger *slog.Logger }