Skip to content

Commit

Permalink
refactor(api/proto): extract filepb package
Browse files Browse the repository at this point in the history
  • Loading branch information
bounoable committed Oct 19, 2022
1 parent 2480f01 commit a865b79
Show file tree
Hide file tree
Showing 6 changed files with 244 additions and 147 deletions.
17 changes: 17 additions & 0 deletions api/proto/gen/file/v0/file.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package filepb

import "github.com/modernice/media-entity/file"

func NewStorage(s file.Storage) *Storage {
return &Storage{
Provider: s.Provider,
Path: s.Path,
}
}

func (s *Storage) AsStorage() file.Storage {
return file.Storage{
Provider: s.GetProvider(),
Path: s.GetPath(),
}
}
157 changes: 157 additions & 0 deletions api/proto/gen/file/v0/storage.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 2 additions & 15 deletions api/proto/gen/image/v0/image.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package imagepb

import (
filepb "github.com/modernice/media-entity/api/proto/gen/file/v0"
"github.com/modernice/media-entity/image"
"github.com/modernice/media-entity/internal/mapx"
"github.com/modernice/media-entity/internal/slicex"
)

func New(img image.Image) *Image {
return &Image{
Storage: NewStorage(img.Storage),
Storage: filepb.NewStorage(img.Storage),
Filename: img.Filename,
Filesize: int64(img.Filesize),
Dimensions: NewDimensions(img.Dimensions),
Expand All @@ -30,20 +31,6 @@ func (img *Image) AsImage() image.Image {
}
}

func NewStorage(s image.Storage) *Storage {
return &Storage{
Provider: s.Provider,
Path: s.Path,
}
}

func (s *Storage) AsStorage() image.Storage {
return image.Storage{
Provider: s.GetProvider(),
Path: s.GetPath(),
}
}

func NewDimensions(d image.Dimensions) *Dimensions {
return &Dimensions{
Width: int64(d.Width()),
Expand Down
Loading

0 comments on commit a865b79

Please sign in to comment.