Skip to content

Commit

Permalink
utils own file
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen3H committed Nov 23, 2024
1 parent 0fe0939 commit eb68836
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 29 deletions.
32 changes: 3 additions & 29 deletions backend/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -67,7 +41,7 @@ func NewApp() *Application {
return &Application{
Settings: NewSettings(),
Persistence: NewPersistence(),
//Utils: NewUtils(),
Utils: NewUtils(),
}
}

Expand Down
32 changes: 32 additions & 0 deletions backend/app/utils.go
Original file line number Diff line number Diff line change
@@ -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)
}
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func main() {
modm8,
modm8.Settings,
modm8.Persistence,
modm8.Utils,
tsAPI,
tsTools,
nexusAPI,
Expand Down

0 comments on commit eb68836

Please sign in to comment.