mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Moving code away from conf package.
This is necessary, as the conf package will hold only configuration, and cannot have dependencies on other packages
This commit is contained in:
parent
2dfa05ceb6
commit
9049d97820
8 changed files with 21 additions and 16 deletions
|
@ -1,43 +0,0 @@
|
|||
package conf
|
||||
|
||||
import (
|
||||
"github.com/deluan/gomate"
|
||||
"github.com/deluan/gomate/ledis"
|
||||
"github.com/deluan/gosonic/domain"
|
||||
"github.com/deluan/gosonic/engine"
|
||||
"github.com/deluan/gosonic/persistence"
|
||||
"github.com/deluan/gosonic/utils"
|
||||
|
||||
"github.com/deluan/gosonic/itunesbridge"
|
||||
"github.com/deluan/gosonic/scanner"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Persistence
|
||||
utils.DefineSingleton(new(domain.ArtistIndexRepository), persistence.NewArtistIndexRepository)
|
||||
utils.DefineSingleton(new(domain.MediaFolderRepository), persistence.NewMediaFolderRepository)
|
||||
utils.DefineSingleton(new(domain.ArtistRepository), persistence.NewArtistRepository)
|
||||
utils.DefineSingleton(new(domain.AlbumRepository), persistence.NewAlbumRepository)
|
||||
utils.DefineSingleton(new(domain.MediaFileRepository), persistence.NewMediaFileRepository)
|
||||
utils.DefineSingleton(new(domain.PlaylistRepository), persistence.NewPlaylistRepository)
|
||||
|
||||
// Engine (Use cases)
|
||||
utils.DefineSingleton(new(engine.PropertyRepository), persistence.NewPropertyRepository)
|
||||
utils.DefineSingleton(new(engine.NowPlayingRepository), persistence.NewNowPlayingRepository)
|
||||
utils.DefineSingleton(new(engine.Browser), engine.NewBrowser)
|
||||
utils.DefineSingleton(new(engine.ListGenerator), engine.NewListGenerator)
|
||||
utils.DefineSingleton(new(engine.Cover), engine.NewCover)
|
||||
utils.DefineSingleton(new(engine.Playlists), engine.NewPlaylists)
|
||||
utils.DefineSingleton(new(engine.Search), engine.NewSearch)
|
||||
utils.DefineSingleton(new(engine.Scrobbler), engine.NewScrobbler)
|
||||
utils.DefineSingleton(new(engine.Ratings), engine.NewRatings)
|
||||
|
||||
utils.DefineSingleton(new(scanner.CheckSumRepository), persistence.NewCheckSumRepository)
|
||||
utils.DefineSingleton(new(scanner.Scanner), scanner.NewItunesScanner)
|
||||
|
||||
// Other dependencies
|
||||
utils.DefineSingleton(new(itunesbridge.ItunesControl), itunesbridge.NewItunesControl)
|
||||
utils.DefineSingleton(new(gomate.DB), func() gomate.DB {
|
||||
return ledis.NewEmbeddedDB(persistence.Db())
|
||||
})
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package conf
|
||||
|
||||
import "mime"
|
||||
|
||||
func init() {
|
||||
mt := map[string]string{
|
||||
".mp3": "audio/mpeg",
|
||||
".ogg": "audio/ogg",
|
||||
".oga": "audio/ogg",
|
||||
".opus": "audio/ogg",
|
||||
".ogx": "application/ogg",
|
||||
".aac": "audio/mp4",
|
||||
".m4a": "audio/mp4",
|
||||
".flac": "audio/flac",
|
||||
".wav": "audio/x-wav",
|
||||
".wma": "audio/x-ms-wma",
|
||||
".ape": "audio/x-monkeys-audio",
|
||||
".mpc": "audio/x-musepack",
|
||||
".shn": "audio/x-shn",
|
||||
".flv": "video/x-flv",
|
||||
".avi": "video/avi",
|
||||
".mpg": "video/mpeg",
|
||||
".mpeg": "video/mpeg",
|
||||
".mp4": "video/mp4",
|
||||
".m4v": "video/x-m4v",
|
||||
".mkv": "video/x-matroska",
|
||||
".mov": "video/quicktime",
|
||||
".wmv": "video/x-ms-wmv",
|
||||
".ogv": "video/ogg",
|
||||
".divx": "video/divx",
|
||||
".m2ts": "video/MP2T",
|
||||
".ts": "video/MP2T",
|
||||
".webm": "video/webm",
|
||||
".gif": "image/gif",
|
||||
".jpg": "image/jpeg",
|
||||
".jpeg": "image/jpeg",
|
||||
".png": "image/png",
|
||||
".bmp": "image/bmp",
|
||||
}
|
||||
|
||||
for ext, typ := range mt {
|
||||
mime.AddExtensionType(ext, typ)
|
||||
}
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
package conf
|
||||
|
||||
import (
|
||||
"github.com/deluan/gosonic/api"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/context"
|
||||
"github.com/astaxie/beego/plugins/cors"
|
||||
"github.com/deluan/gosonic/controllers"
|
||||
)
|
||||
|
||||
func init() {
|
||||
mapEndpoints()
|
||||
mapControllers()
|
||||
initFilters()
|
||||
}
|
||||
|
||||
func mapEndpoints() {
|
||||
ns := beego.NewNamespace("/rest",
|
||||
beego.NSRouter("/ping.view", &api.SystemController{}, "*:Ping"),
|
||||
beego.NSRouter("/getLicense.view", &api.SystemController{}, "*:GetLicense"),
|
||||
|
||||
beego.NSRouter("/getMusicFolders.view", &api.BrowsingController{}, "*:GetMusicFolders"),
|
||||
beego.NSRouter("/getIndexes.view", &api.BrowsingController{}, "*:GetIndexes"),
|
||||
beego.NSRouter("/getMusicDirectory.view", &api.BrowsingController{}, "*:GetMusicDirectory"),
|
||||
beego.NSRouter("/getSong.view", &api.BrowsingController{}, "*:GetSong"),
|
||||
beego.NSRouter("/getArtists.view", &api.BrowsingController{}, "*:GetArtists"),
|
||||
beego.NSRouter("/getArtist.view", &api.BrowsingController{}, "*:GetArtist"),
|
||||
beego.NSRouter("/getAlbum.view", &api.BrowsingController{}, "*:GetAlbum"),
|
||||
|
||||
beego.NSRouter("/search2.view", &api.SearchingController{}, "*:Search2"),
|
||||
beego.NSRouter("/search3.view", &api.SearchingController{}, "*:Search3"),
|
||||
|
||||
beego.NSRouter("/getCoverArt.view", &api.MediaRetrievalController{}, "*:GetCoverArt"),
|
||||
beego.NSRouter("/getAvatar.view", &api.MediaRetrievalController{}, "*:GetAvatar"),
|
||||
beego.NSRouter("/stream.view", &api.StreamController{}, "*:Stream"),
|
||||
beego.NSRouter("/download.view", &api.StreamController{}, "*:Download"),
|
||||
|
||||
beego.NSRouter("/scrobble.view", &api.MediaAnnotationController{}, "*:Scrobble"),
|
||||
beego.NSRouter("/star.view", &api.MediaAnnotationController{}, "*:Star"),
|
||||
beego.NSRouter("/unstar.view", &api.MediaAnnotationController{}, "*:Unstar"),
|
||||
beego.NSRouter("/setRating.view", &api.MediaAnnotationController{}, "*:SetRating"),
|
||||
|
||||
beego.NSRouter("/getAlbumList.view", &api.AlbumListController{}, "*:GetAlbumList"),
|
||||
beego.NSRouter("/getAlbumList2.view", &api.AlbumListController{}, "*:GetAlbumList2"),
|
||||
beego.NSRouter("/getStarred.view", &api.AlbumListController{}, "*:GetStarred"),
|
||||
beego.NSRouter("/getStarred2.view", &api.AlbumListController{}, "*:GetStarred2"),
|
||||
beego.NSRouter("/getNowPlaying.view", &api.AlbumListController{}, "*:GetNowPlaying"),
|
||||
beego.NSRouter("/getRandomSongs.view", &api.AlbumListController{}, "*:GetRandomSongs"),
|
||||
|
||||
beego.NSRouter("/getPlaylists.view", &api.PlaylistsController{}, "*:GetPlaylists"),
|
||||
beego.NSRouter("/getPlaylist.view", &api.PlaylistsController{}, "*:GetPlaylist"),
|
||||
beego.NSRouter("/createPlaylist.view", &api.PlaylistsController{}, "*:CreatePlaylist"),
|
||||
beego.NSRouter("/updatePlaylist.view", &api.PlaylistsController{}, "*:UpdatePlaylist"),
|
||||
beego.NSRouter("/deletePlaylist.view", &api.PlaylistsController{}, "*:DeletePlaylist"),
|
||||
|
||||
beego.NSRouter("/getUser.view", &api.UsersController{}, "*:GetUser"),
|
||||
)
|
||||
beego.AddNamespace(ns)
|
||||
|
||||
}
|
||||
|
||||
func mapControllers() {
|
||||
beego.Router("/", &controllers.MainController{})
|
||||
beego.Router("/sync", &controllers.SyncController{})
|
||||
|
||||
beego.ErrorController(&controllers.MainController{})
|
||||
}
|
||||
|
||||
func initFilters() {
|
||||
var ValidateRequest = func(ctx *context.Context) {
|
||||
c := api.BaseAPIController{}
|
||||
c.Ctx = ctx
|
||||
c.Data = make(map[interface{}]interface{})
|
||||
api.Validate(c)
|
||||
}
|
||||
beego.InsertFilter("/rest/*", beego.BeforeRouter, cors.Allow(&cors.Options{
|
||||
AllowOrigins: []string{"*"},
|
||||
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
|
||||
AllowHeaders: []string{"Origin", "Authorization", "Access-Control-Allow-Origin"},
|
||||
ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin"},
|
||||
AllowCredentials: true,
|
||||
}))
|
||||
|
||||
beego.InsertFilter("/rest/*", beego.BeforeRouter, ValidateRequest)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue