matheusgomes28 / urchin

Headless CMS written in Golang
MIT License
46 stars 15 forks source link

Abstract image file access #65

Open matheusgomes28 opened 4 months ago

matheusgomes28 commented 4 months ago

Make the access to the image files happen through an interface. This would make testing the actual business logic of the image endpoints a little easier, so we don't rely on the file system.

For e2e tests, we can still use the filesystem!

This is similar to the Database interface we have, but for the images.

rafiramadhana commented 4 months ago

Hi @matheusgomes28 , this issue seems interesting to work

However, I have some questions here:

matheusgomes28 commented 4 months ago

Hey @rafiramadhana , thanks for your interest in this task !

Yes, it does depend on that task as the get endpoint for the images need to be merged in for us to abstract it. It should be merged as soon as the suggestions in the PR are fixed 😄

rafiramadhana commented 4 months ago

Yes, it does depend on that task as the get endpoint for the images need to be merged in for us to abstract it. It should be merged as soon as the suggestions in the PR are fixed 😄

Got it. So, let's wait until #64 get merged.

matheusgomes28 commented 4 months ago

64 is now merged FYI

rafiramadhana commented 4 months ago

@matheusgomes28 Hi, I've just skimmed through the codebase, let's assume we will name our interface as MediaVault (as mentioned here)

MediaVault will have 3 methods (this is very open to discussions and suggestions)

type MediaVault interface {
    Add(string) error
    Get(string) ([]byte, error)
    Remove(string) error
}

// Example
err := mv.Add("/file.txt")

b, err := mv.Get("/file.txt")

err := mv.Delete("/file.txt")

MediaVault will be implemented in given endpoints:

ADMIN

NON-ADMIN

Wdyt?