diff --git a/backend/app/app.go b/backend/app/app.go index c5fc91d..6741613 100644 --- a/backend/app/app.go +++ b/backend/app/app.go @@ -23,38 +23,12 @@ var ( ) type Application struct { - Ctx context.Context - //Utils *Utils `json:"utils"` + Ctx context.Context + Utils *Utils `json:"utils"` Settings *AppSettings `json:"settings"` Persistence *Persistence `json:"persistence"` } -// type Utils struct{} - -// func NewUtils() *Utils { -// return &Utils{} -// } - -// func (u *Utils) ExistsInDir(dir, item string) (bool, error) { -// return backend.ExistsInDir(dir, item) -// } - -// func (u Utils) ExistsAtPath(path string, clean bool) (bool, error) { -// if clean { -// path = filepath.Clean(path) -// } - -// return backend.ExistsAtPath(path) -// } - -// func (u *Utils) GetDirsAtPath(path string, exts []string) ([]string, error) { -// return backend.GetDirsAtPath(path) -// } - -// func (u *Utils) GetFilesWithExts(path string, exts []string) ([]string, error) { -// return backend.GetFilesWithExts(path, exts) -// } - func (app *Application) GetSettings() *AppSettings { return app.Settings } @@ -67,7 +41,7 @@ func NewApp() *Application { return &Application{ Settings: NewSettings(), Persistence: NewPersistence(), - //Utils: NewUtils(), + Utils: NewUtils(), } } diff --git a/backend/app/utils.go b/backend/app/utils.go new file mode 100644 index 0000000..f7d72eb --- /dev/null +++ b/backend/app/utils.go @@ -0,0 +1,32 @@ +package app + +import ( + "modm8/backend" + "path/filepath" +) + +type Utils struct{} + +func NewUtils() *Utils { + return &Utils{} +} + +func (u *Utils) ExistsInDir(dir, item string) (bool, error) { + return backend.ExistsInDir(dir, item) +} + +func (u Utils) ExistsAtPath(path string, clean bool) (bool, error) { + if clean { + path = filepath.Clean(path) + } + + return backend.ExistsAtPath(path) +} + +func (u *Utils) GetDirsAtPath(path string, exts []string) ([]string, error) { + return backend.GetDirsAtPath(path) +} + +func (u *Utils) GetFilesWithExts(path string, exts []string) ([]string, error) { + return backend.GetFilesWithExts(path, exts) +} diff --git a/main.go b/main.go index 32d064b..90892ca 100644 --- a/main.go +++ b/main.go @@ -102,6 +102,7 @@ func main() { modm8, modm8.Settings, modm8.Persistence, + modm8.Utils, tsAPI, tsTools, nexusAPI,