mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-04 13:07:36 +03:00
57 lines
1.7 KiB
Go
57 lines
1.7 KiB
Go
//+build wireinject
|
|
|
|
package main
|
|
|
|
import (
|
|
"github.com/cloudsonic/sonic-server/api"
|
|
"github.com/cloudsonic/sonic-server/domain"
|
|
"github.com/cloudsonic/sonic-server/engine"
|
|
"github.com/cloudsonic/sonic-server/itunesbridge"
|
|
"github.com/cloudsonic/sonic-server/persistence/db_sql"
|
|
"github.com/cloudsonic/sonic-server/scanner"
|
|
"github.com/cloudsonic/sonic-server/server"
|
|
"github.com/google/wire"
|
|
)
|
|
|
|
type Provider struct {
|
|
AlbumRepository domain.AlbumRepository
|
|
ArtistRepository domain.ArtistRepository
|
|
CheckSumRepository scanner.CheckSumRepository
|
|
ArtistIndexRepository domain.ArtistIndexRepository
|
|
MediaFileRepository domain.MediaFileRepository
|
|
MediaFolderRepository domain.MediaFolderRepository
|
|
NowPlayingRepository domain.NowPlayingRepository
|
|
PlaylistRepository domain.PlaylistRepository
|
|
PropertyRepository domain.PropertyRepository
|
|
}
|
|
|
|
var allProviders = wire.NewSet(
|
|
itunesbridge.NewItunesControl,
|
|
engine.Set,
|
|
scanner.Set,
|
|
api.NewRouter,
|
|
wire.FieldsOf(new(*Provider), "AlbumRepository", "ArtistRepository", "CheckSumRepository",
|
|
"ArtistIndexRepository", "MediaFileRepository", "MediaFolderRepository", "NowPlayingRepository",
|
|
"PlaylistRepository", "PropertyRepository"),
|
|
createPersistenceProvider,
|
|
)
|
|
|
|
func CreateApp(musicFolder string) *server.Server {
|
|
panic(wire.Build(
|
|
server.New,
|
|
allProviders,
|
|
))
|
|
}
|
|
|
|
func CreateSubsonicAPIRouter() *api.Router {
|
|
panic(wire.Build(allProviders))
|
|
}
|
|
|
|
// When implementing a different persistence layer, duplicate this function (in separated files) and use build tags
|
|
// to conditionally select which function to use
|
|
func createPersistenceProvider() *Provider {
|
|
panic(wire.Build(
|
|
db_sql.Set,
|
|
wire.Struct(new(Provider), "*"),
|
|
))
|
|
}
|