mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
100 lines
1.8 KiB
Go
100 lines
1.8 KiB
Go
//go:build wireinject
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/google/wire"
|
|
"github.com/navidrome/navidrome/core"
|
|
"github.com/navidrome/navidrome/core/agents/lastfm"
|
|
"github.com/navidrome/navidrome/core/agents/listenbrainz"
|
|
"github.com/navidrome/navidrome/core/artwork"
|
|
"github.com/navidrome/navidrome/db"
|
|
"github.com/navidrome/navidrome/persistence"
|
|
"github.com/navidrome/navidrome/scanner"
|
|
"github.com/navidrome/navidrome/server"
|
|
"github.com/navidrome/navidrome/server/events"
|
|
"github.com/navidrome/navidrome/server/nativeapi"
|
|
"github.com/navidrome/navidrome/server/public"
|
|
"github.com/navidrome/navidrome/server/shares"
|
|
"github.com/navidrome/navidrome/server/subsonic"
|
|
)
|
|
|
|
var allProviders = wire.NewSet(
|
|
core.Set,
|
|
artwork.Set,
|
|
subsonic.New,
|
|
nativeapi.New,
|
|
public.New,
|
|
shares.New,
|
|
persistence.New,
|
|
lastfm.NewRouter,
|
|
listenbrainz.NewRouter,
|
|
events.GetBroker,
|
|
db.Db,
|
|
)
|
|
|
|
func CreateServer(musicFolder string) *server.Server {
|
|
panic(wire.Build(
|
|
server.New,
|
|
allProviders,
|
|
))
|
|
}
|
|
|
|
func CreateNativeAPIRouter() *nativeapi.Router {
|
|
panic(wire.Build(
|
|
allProviders,
|
|
))
|
|
}
|
|
|
|
func CreateSubsonicAPIRouter() *subsonic.Router {
|
|
panic(wire.Build(
|
|
allProviders,
|
|
GetScanner,
|
|
))
|
|
}
|
|
|
|
func CreatePublicRouter() *public.Router {
|
|
panic(wire.Build(
|
|
allProviders,
|
|
))
|
|
}
|
|
|
|
func CreateSharesRouter() *shares.Router {
|
|
panic(wire.Build(
|
|
allProviders,
|
|
))
|
|
}
|
|
|
|
func CreateLastFMRouter() *lastfm.Router {
|
|
panic(wire.Build(
|
|
allProviders,
|
|
))
|
|
}
|
|
|
|
func CreateListenBrainzRouter() *listenbrainz.Router {
|
|
panic(wire.Build(
|
|
allProviders,
|
|
))
|
|
}
|
|
|
|
// 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,
|
|
))
|
|
}
|