diff --git a/.env.example b/.env.example
index 4a85ca47..e46503ed 100644
--- a/.env.example
+++ b/.env.example
@@ -1,7 +1,12 @@
+# Useful config options
+LIBRARY_ROOT=./video
TVDB__APIKEY=
THEMOVIEDB__APIKEY=
-AUTHENTICATION_SECRET=
PUBLIC_BACK_URL=http://localhost:5000
+AUTHENTICATION_SECRET=
+
+# To debug the front end, you can set the following to an external backend
+KYOO_URL=https://kyoo.sdg.moe/api
# Database things (optional)
POSTGRES_USER=KyooUser
diff --git a/back/Dockerfile b/back/Dockerfile
index dcbd08ed..45e1ffb1 100644
--- a/back/Dockerfile
+++ b/back/Dockerfile
@@ -5,17 +5,15 @@ COPY src/Kyoo.Transcoder .
RUN cmake . && make -j
FROM mcr.microsoft.com/dotnet/sdk:6.0 as builder
-WORKDIR /kyoo
COPY Kyoo.sln ./Kyoo.sln
COPY nuget.config ./nuget.config
COPY src/Directory.Build.props src/Directory.Build.props
COPY src/Kyoo.Authentication/Kyoo.Authentication.csproj src/Kyoo.Authentication/Kyoo.Authentication.csproj
-COPY src/Kyoo.Host.Generic/Kyoo.Host.Generic.csproj src/Kyoo.Host.Generic/Kyoo.Host.Generic.csproj
COPY src/Kyoo.TheMovieDb/Kyoo.TheMovieDb.csproj src/Kyoo.TheMovieDb/Kyoo.TheMovieDb.csproj
COPY src/Kyoo.Abstractions/Kyoo.Abstractions.csproj src/Kyoo.Abstractions/Kyoo.Abstractions.csproj
COPY src/Kyoo.Core/Kyoo.Core.csproj src/Kyoo.Core/Kyoo.Core.csproj
-COPY src/Kyoo.Host.Console/Kyoo.Host.Console.csproj src/Kyoo.Host.Console/Kyoo.Host.Console.csproj
+COPY src/Kyoo.Host/Kyoo.Host.csproj src/Kyoo.Host/Kyoo.Host.csproj
COPY src/Kyoo.Postgresql/Kyoo.Postgresql.csproj src/Kyoo.Postgresql/Kyoo.Postgresql.csproj
COPY src/Kyoo.Swagger/Kyoo.Swagger.csproj src/Kyoo.Swagger/Kyoo.Swagger.csproj
COPY src/Kyoo.TheTvdb/Kyoo.TheTvdb.csproj src/Kyoo.TheTvdb/Kyoo.TheTvdb.csproj
@@ -24,12 +22,14 @@ RUN dotnet restore
COPY . .
ARG VERSION
-RUN dotnet publish --no-restore -c Release -o /opt/kyoo "-p:Version=${VERSION:-"0.0.0-dev"};SkipTranscoder=true" src/Kyoo.Host.Console
+RUN dotnet publish --no-restore -c Release -o /app "-p:Version=${VERSION:-"0.0.0-dev"};SkipTranscoder=true" src/Kyoo.Host
FROM mcr.microsoft.com/dotnet/aspnet:6.0
RUN apt-get update && apt-get install -y libavutil-dev libavcodec-dev libavformat-dev
-EXPOSE 5000
-COPY --from=builder /opt/kyoo /usr/lib/kyoo
+COPY --from=builder /app /app
COPY --from=transcoder /transcoder/libtranscoder.so /usr/lib/kyoo
-CMD ["/usr/lib/kyoo/Kyoo.Host.Console"]
+
+WORKDIR /kyoo
+EXPOSE 5000
+CMD ["/app/Kyoo.Host"]
diff --git a/back/Dockerfile.dev b/back/Dockerfile.dev
index 00f0b274..9851073d 100644
--- a/back/Dockerfile.dev
+++ b/back/Dockerfile.dev
@@ -8,26 +8,24 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0
RUN apt-get update && apt-get install -y libavutil-dev libavcodec-dev libavformat-dev
WORKDIR /app
-
COPY Kyoo.sln ./Kyoo.sln
COPY nuget.config ./nuget.config
COPY src/Directory.Build.props src/Directory.Build.props
COPY src/Kyoo.Authentication/Kyoo.Authentication.csproj src/Kyoo.Authentication/Kyoo.Authentication.csproj
-COPY src/Kyoo.Host.Generic/Kyoo.Host.Generic.csproj src/Kyoo.Host.Generic/Kyoo.Host.Generic.csproj
COPY src/Kyoo.TheMovieDb/Kyoo.TheMovieDb.csproj src/Kyoo.TheMovieDb/Kyoo.TheMovieDb.csproj
COPY src/Kyoo.Abstractions/Kyoo.Abstractions.csproj src/Kyoo.Abstractions/Kyoo.Abstractions.csproj
COPY src/Kyoo.Core/Kyoo.Core.csproj src/Kyoo.Core/Kyoo.Core.csproj
-COPY src/Kyoo.Host.Console/Kyoo.Host.Console.csproj src/Kyoo.Host.Console/Kyoo.Host.Console.csproj
+COPY src/Kyoo.Host/Kyoo.Host.csproj src/Kyoo.Host/Kyoo.Host.csproj
COPY src/Kyoo.Postgresql/Kyoo.Postgresql.csproj src/Kyoo.Postgresql/Kyoo.Postgresql.csproj
COPY src/Kyoo.Swagger/Kyoo.Swagger.csproj src/Kyoo.Swagger/Kyoo.Swagger.csproj
COPY src/Kyoo.TheTvdb/Kyoo.TheTvdb.csproj src/Kyoo.TheTvdb/Kyoo.TheTvdb.csproj
COPY tests/Kyoo.Tests/Kyoo.Tests.csproj tests/Kyoo.Tests/Kyoo.Tests.csproj
-
RUN dotnet restore
COPY --from=transcoder /transcoder/libtranscoder.so /usr/lib/
+WORKDIR /kyoo
EXPOSE 5000
ENV DOTNET_USE_POLLING_FILE_WATCHER 1
-CMD ["dotnet", "watch", "run", "--no-restore", "--project", "src/Kyoo.Host.Console"]
+CMD ["dotnet", "watch", "run", "--no-restore", "--project", "/app/src/Kyoo.Host"]
diff --git a/back/Kyoo.sln b/back/Kyoo.sln
index 6a618cb7..134e4daa 100644
--- a/back/Kyoo.sln
+++ b/back/Kyoo.sln
@@ -13,19 +13,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.TheMovieDb", "src\Kyoo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.Tests", "tests\Kyoo.Tests\Kyoo.Tests.csproj", "{0C8AA7EA-E723-4532-852F-35AA4E8AFED5}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.Host.Console", "src\Kyoo.Host.Console\Kyoo.Host.Console.csproj", "{D8658BEA-8949-45AC-BEBB-A4FFC4F800F5}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.Swagger", "src\Kyoo.Swagger\Kyoo.Swagger.csproj", "{7D1A7596-73F6-4D35-842E-A5AD9C620596}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{FEAE1B0E-D797-470F-9030-0EF743575ECC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Providers", "Providers", "{8D28F5EF-0CD7-4697-A2A7-24EC31A48F21}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Databases", "Databases", "{865461CA-EC06-4B42-91CF-8723B0A9BB67}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Hosts", "Hosts", "{C569FF25-7E01-484C-9F72-5B99845AD94B}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.Host.Generic", "src\Kyoo.Host.Generic\Kyoo.Host.Generic.csproj", "{0938459E-2E2B-457F-8120-7D8CA93866A6}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.Host", "src\Kyoo.Host\Kyoo.Host.csproj", "{0938459E-2E2B-457F-8120-7D8CA93866A6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -73,10 +67,6 @@ Global
{4FF1ECD9-6EEF-4440-B037-A661D78FB04D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4FF1ECD9-6EEF-4440-B037-A661D78FB04D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4FF1ECD9-6EEF-4440-B037-A661D78FB04D}.Release|Any CPU.Build.0 = Release|Any CPU
- {D8658BEA-8949-45AC-BEBB-A4FFC4F800F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {D8658BEA-8949-45AC-BEBB-A4FFC4F800F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {D8658BEA-8949-45AC-BEBB-A4FFC4F800F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {D8658BEA-8949-45AC-BEBB-A4FFC4F800F5}.Release|Any CPU.Build.0 = Release|Any CPU
{7D1A7596-73F6-4D35-842E-A5AD9C620596}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7D1A7596-73F6-4D35-842E-A5AD9C620596}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7D1A7596-73F6-4D35-842E-A5AD9C620596}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -90,9 +80,5 @@ Global
{0C8AA7EA-E723-4532-852F-35AA4E8AFED5} = {FEAE1B0E-D797-470F-9030-0EF743575ECC}
{BAB270D4-E0EA-4329-BA65-512FDAB01001} = {8D28F5EF-0CD7-4697-A2A7-24EC31A48F21}
{D06BF829-23F5-40F3-A62D-627D9F4B4D6C} = {8D28F5EF-0CD7-4697-A2A7-24EC31A48F21}
- {3213C96D-0BF3-460B-A8B5-B9977229408A} = {865461CA-EC06-4B42-91CF-8723B0A9BB67}
- {6515380E-1E57-42DA-B6E3-E1C8A848818A} = {865461CA-EC06-4B42-91CF-8723B0A9BB67}
- {D8658BEA-8949-45AC-BEBB-A4FFC4F800F5} = {C569FF25-7E01-484C-9F72-5B99845AD94B}
- {0938459E-2E2B-457F-8120-7D8CA93866A6} = {C569FF25-7E01-484C-9F72-5B99845AD94B}
EndGlobalSection
EndGlobal
diff --git a/back/src/Kyoo.Abstractions/Controllers/IApplication.cs b/back/src/Kyoo.Abstractions/Controllers/IApplication.cs
deleted file mode 100644
index 11c396dd..00000000
--- a/back/src/Kyoo.Abstractions/Controllers/IApplication.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-// Kyoo - A portable and vast media library solution.
-// Copyright (c) Kyoo.
-//
-// See AUTHORS.md and LICENSE file in the project root for full license information.
-//
-// Kyoo is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// any later version.
-//
-// Kyoo is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Kyoo. If not, see .
-
-namespace Kyoo.Abstractions.Controllers
-{
- ///
- /// An interface that allow one to interact with the host and shutdown or restart the app.
- ///
- public interface IApplication
- {
- ///
- /// Shutdown the process and stop gracefully.
- ///
- void Shutdown();
-
- ///
- /// Restart Kyoo from scratch, reload plugins, configurations and restart the web server.
- ///
- void Restart();
-
- ///
- /// Get the data directory.
- ///
- /// Retrieve the data directory where runtime data should be stored.
- string GetDataDirectory();
-
- ///
- /// Retrieve the path of the json configuration file
- /// (relative to the data directory, see ).
- ///
- /// The configuration file name.
- string GetConfigFile();
- }
-}
diff --git a/back/src/Kyoo.Abstractions/Controllers/IConfigurationManager.cs b/back/src/Kyoo.Abstractions/Controllers/IConfigurationManager.cs
deleted file mode 100644
index b5c57565..00000000
--- a/back/src/Kyoo.Abstractions/Controllers/IConfigurationManager.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-// Kyoo - A portable and vast media library solution.
-// Copyright (c) Kyoo.
-//
-// See AUTHORS.md and LICENSE file in the project root for full license information.
-//
-// Kyoo is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// any later version.
-//
-// Kyoo is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Kyoo. If not, see .
-
-using System;
-using System.Threading.Tasks;
-using JetBrains.Annotations;
-using Kyoo.Abstractions.Models;
-using Kyoo.Abstractions.Models.Exceptions;
-
-namespace Kyoo.Abstractions.Controllers
-{
- ///
- /// A class to ease configuration management. This work WITH Microsoft's package, you can still use IOptions patterns
- /// to access your options, this manager ease dynamic work and editing.
- /// It works with .
- ///
- public interface IConfigurationManager
- {
- ///
- /// Add an editable configuration to the editable configuration list.
- ///
- /// The root path of the editable configuration. It should not be a nested type.
- /// The type of the configuration.
- void AddTyped(string path);
-
- ///
- /// Add an editable configuration to the editable configuration list.
- /// WARNING: this method allow you to add an unmanaged type. This type won't be editable. This can be used
- /// for external libraries or variable arguments.
- ///
- /// The root path of the editable configuration. It should not be a nested type.
- void AddUntyped(string path);
-
- ///
- /// An helper method of and .
- /// This register a typed value if is not null and registers an untyped type
- /// if is null.
- ///
- /// The root path of the editable configuration. It should not be a nested type.
- /// The type of the configuration or null.
- void Register(string path, [CanBeNull] Type type);
-
- ///
- /// Get the value of a setting using it's path.
- ///
- /// The path of the resource (can be separated by ':' or '__').
- /// No setting found at the given path.
- /// The value of the settings (if it's a strongly typed one, the given type is instantiated.
- object GetValue(string path);
-
- ///
- /// Get the value of a setting using it's path.
- /// If your don't need a strongly typed value, see .
- ///
- /// The path of the resource (can be separated by ':' or '__').
- /// A type to strongly type your option.
- /// If your type is not the same as the registered type.
- /// No setting found at the given path.
- /// The value of the settings (if it's a strongly typed one, the given type is instantiated.
- T GetValue(string path);
-
- ///
- /// Edit the value of a setting using it's path. Save it to the json file.
- ///
- /// The path of the resource (can be separated by ':' or '__').
- /// The new value of the resource.
- /// No setting found at the given path.
- /// A representing the asynchronous operation.
- Task EditValue(string path, object value);
- }
-}
diff --git a/back/src/Kyoo.Core/Controllers/ConfigurationManager.cs b/back/src/Kyoo.Core/Controllers/ConfigurationManager.cs
deleted file mode 100644
index ba3372ad..00000000
--- a/back/src/Kyoo.Core/Controllers/ConfigurationManager.cs
+++ /dev/null
@@ -1,220 +0,0 @@
-// Kyoo - A portable and vast media library solution.
-// Copyright (c) Kyoo.
-//
-// See AUTHORS.md and LICENSE file in the project root for full license information.
-//
-// Kyoo is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// any later version.
-//
-// Kyoo is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Kyoo. If not, see .
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Dynamic;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-using Kyoo.Abstractions.Controllers;
-using Kyoo.Abstractions.Models;
-using Kyoo.Abstractions.Models.Exceptions;
-using Kyoo.Core.Api;
-using Microsoft.Extensions.Configuration;
-using Newtonsoft.Json.Linq;
-
-namespace Kyoo.Core.Controllers
-{
- ///
- /// A class to ease configuration management. This work WITH Microsoft's package, you can still use IOptions patterns
- /// to access your options, this manager ease dynamic work and editing.
- /// It works with .
- ///
- public class ConfigurationManager : IConfigurationManager
- {
- ///
- /// The configuration to retrieve and edit.
- ///
- private readonly IConfiguration _configuration;
-
- ///
- /// The application running Kyoo, it is used to retrieve the configuration file.
- ///
- private readonly IApplication _application;
-
- ///
- /// The strongly typed list of options
- ///
- private readonly Dictionary _references;
-
- ///
- /// Create a new using the given configuration.
- ///
- /// The configuration to use.
- /// The strongly typed option list.
- /// The application running Kyoo, it is used to retrieve the configuration file.
- public ConfigurationManager(IConfiguration configuration, IEnumerable references, IApplication application)
- {
- _configuration = configuration;
- _application = application;
- _references = references.ToDictionary(x => x.Path, x => x.Type, StringComparer.OrdinalIgnoreCase);
- }
-
- ///
- /// Transform the configuration section in nested expando objects.
- ///
- /// The section to convert
- /// The converted section
- private static object _ToUntyped(IConfigurationSection config)
- {
- ExpandoObject obj = new();
-
- foreach (IConfigurationSection section in config.GetChildren())
- {
- obj.TryAdd(section.Key, _ToUntyped(section));
- }
-
- if (!obj.Any())
- return config.Value;
- return obj;
- }
-
- ///
- public void AddTyped(string path)
- {
- foreach (ConfigurationReference confRef in ConfigurationReference.CreateReference(path))
- _references.Add(confRef.Path, confRef.Type);
- }
-
- ///
- public void AddUntyped(string path)
- {
- ConfigurationReference config = ConfigurationReference.CreateUntyped(path);
- _references.Add(config.Path, config.Type);
- }
-
- ///
- public void Register(string path, Type type)
- {
- if (type == null)
- {
- ConfigurationReference config = ConfigurationReference.CreateUntyped(path);
- _references.Add(config.Path, config.Type);
- }
- else
- {
- foreach (ConfigurationReference confRef in ConfigurationReference.CreateReference(path, type))
- _references.Add(confRef.Path, confRef.Type);
- }
- }
-
- ///
- /// Get the type of the resource at the given path
- ///
- /// The path of the resource
- /// The path is not editable or readable
- /// No configuration exists for the given path
- /// The type of the resource at the given path
- private Type _GetType(string path)
- {
- path = path.Replace("__", ":");
-
- // TODO handle lists and dictionaries.
- if (_references.TryGetValue(path, out Type type))
- {
- if (type != null)
- return type;
- throw new ArgumentException($"The configuration at {path} is not editable or readable.");
- }
-
- string parent = path.Contains(':') ? path[..path.IndexOf(':')] : null;
- if (parent != null && _references.TryGetValue(parent, out type) && type == null)
- throw new ArgumentException($"The configuration at {path} is not editable or readable.");
- throw new ItemNotFoundException($"No configuration exists for the name: {path}");
- }
-
- ///
- public object GetValue(string path)
- {
- path = path.Replace("__", ":");
- // TODO handle lists and dictionaries.
- Type type = _GetType(path);
- object ret = _configuration.GetValue(type, path);
- if (ret != null)
- return ret;
- object option = Activator.CreateInstance(type);
- _configuration.Bind(path, option);
- return option;
- }
-
- ///
- public T GetValue(string path)
- {
- path = path.Replace("__", ":");
- // TODO handle lists and dictionaries.
- Type type = _GetType(path);
- if (typeof(T).IsAssignableFrom(type))
- {
- throw new InvalidCastException($"The type {typeof(T).Name} is not valid for " +
- $"a resource of type {type.Name}.");
- }
- return (T)GetValue(path);
- }
-
- ///
- public async Task EditValue(string path, object value)
- {
- path = path.Replace("__", ":");
- Type type = _GetType(path);
- value = JObject.FromObject(value).ToObject(type);
- if (value == null)
- throw new ArgumentException("Invalid value format.");
-
- ExpandoObject config = _ToObject(_configuration);
- IDictionary configDic = config;
- configDic[path] = value;
- JObject obj = JObject.FromObject(config);
- await using StreamWriter writer = new(_application.GetConfigFile());
- await writer.WriteAsync(obj.ToString());
- }
-
- ///
- /// Transform a configuration to a strongly typed object (the root configuration is an
- /// but child elements are using strong types.
- ///
- /// The configuration to transform
- /// A strongly typed representation of the configuration.
- [SuppressMessage("ReSharper", "RedundantJumpStatement",
- Justification = "A catch block should not be empty.")]
- private ExpandoObject _ToObject(IConfiguration config)
- {
- ExpandoObject obj = new();
-
- foreach (IConfigurationSection section in config.GetChildren())
- {
- try
- {
- Type type = _GetType(section.Path);
- obj.TryAdd(section.Key, section.Get(type));
- }
- catch (ArgumentException)
- {
- obj.TryAdd(section.Key, _ToUntyped(section));
- }
- catch
- {
- continue;
- }
- }
-
- return obj;
- }
- }
-}
diff --git a/back/src/Kyoo.Core/CoreModule.cs b/back/src/Kyoo.Core/CoreModule.cs
index 3366c80b..0436779b 100644
--- a/back/src/Kyoo.Core/CoreModule.cs
+++ b/back/src/Kyoo.Core/CoreModule.cs
@@ -66,7 +66,6 @@ namespace Kyoo.Core
builder.RegisterType().As().SingleInstance();
builder.RegisterType().As().SingleInstance();
- builder.RegisterType().As().SingleInstance();
builder.RegisterType().As().SingleInstance();
builder.RegisterType().As().InstancePerLifetimeScope();
builder.RegisterType().As().InstancePerLifetimeScope();
diff --git a/back/src/Kyoo.Core/Views/Admin/ConfigurationApi.cs b/back/src/Kyoo.Core/Views/Admin/ConfigurationApi.cs
deleted file mode 100644
index e1d51bb7..00000000
--- a/back/src/Kyoo.Core/Views/Admin/ConfigurationApi.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-// Kyoo - A portable and vast media library solution.
-// Copyright (c) Kyoo.
-//
-// See AUTHORS.md and LICENSE file in the project root for full license information.
-//
-// Kyoo is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// any later version.
-//
-// Kyoo is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Kyoo. If not, see .
-
-using System.Threading.Tasks;
-using Kyoo.Abstractions.Controllers;
-using Kyoo.Abstractions.Models.Attributes;
-using Kyoo.Abstractions.Models.Permissions;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-using static Kyoo.Abstractions.Models.Utils.Constants;
-
-namespace Kyoo.Core.Api
-{
- ///
- /// An API to retrieve or edit configuration settings
- ///
- [Route("configuration")]
- [Route("config", Order = AlternativeRoute)]
- [ApiController]
- [PartialPermission("Configuration", Group = Group.Admin)]
- [ApiDefinition("Configuration", Group = AdminGroup)]
- public class ConfigurationApi : Controller
- {
- ///
- /// The configuration manager used to retrieve and edit configuration values (while being type safe).
- ///
- private readonly IConfigurationManager _manager;
-
- ///
- /// Create a new using the given configuration.
- ///
- /// The configuration manager used to retrieve and edit configuration values
- public ConfigurationApi(IConfigurationManager manager)
- {
- _manager = manager;
- }
-
- ///
- /// Get config value
- ///
- ///
- /// Retrieve a configuration's value from it's slug.
- ///
- /// The permission to retrieve. You can use ':' or "__" to get a child value.
- /// The associate value or list of values.
- /// Return the configuration value or the list of configurations
- /// No configuration exists for the given slug
- [HttpGet("{slug}")]
- [PartialPermission(Kind.Read)]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- public ActionResult