mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
59 lines
1 KiB
Go
59 lines
1 KiB
Go
//+build wireinject
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"github.com/deluan/navidrome/core"
|
|
"github.com/deluan/navidrome/persistence"
|
|
"github.com/deluan/navidrome/scanner"
|
|
"github.com/deluan/navidrome/server"
|
|
"github.com/deluan/navidrome/server/app"
|
|
"github.com/deluan/navidrome/server/subsonic"
|
|
"github.com/google/wire"
|
|
"sync"
|
|
)
|
|
|
|
var allProviders = wire.NewSet(
|
|
core.Set,
|
|
subsonic.New,
|
|
app.New,
|
|
persistence.New,
|
|
)
|
|
|
|
func CreateServer(musicFolder string) *server.Server {
|
|
panic(wire.Build(
|
|
server.New,
|
|
allProviders,
|
|
))
|
|
}
|
|
|
|
func CreateAppRouter() *app.Router {
|
|
panic(wire.Build(allProviders))
|
|
}
|
|
|
|
func CreateSubsonicAPIRouter() *subsonic.Router {
|
|
panic(wire.Build(
|
|
allProviders,
|
|
GetScanner,
|
|
))
|
|
}
|
|
|
|
// Scanner must be a Singleton
|
|
var (
|
|
onceScanner sync.Once
|
|
scannerInstance scanner.Scanner
|
|
)
|
|
|
|
func GetScanner() scanner.Scanner {
|
|
onceScanner.Do(func() {
|
|
scannerInstance = createScanner()
|
|
})
|
|
return scannerInstance
|
|
}
|
|
|
|
func createScanner() scanner.Scanner {
|
|
panic(wire.Build(
|
|
allProviders,
|
|
scanner.New,
|
|
))
|
|
}
|