diff options
Diffstat (limited to 'back-end')
-rw-r--r-- | back-end/src/Endpoints/BmAccountEndpoint.cs | 8 | ||||
-rw-r--r-- | back-end/src/Endpoints/BookmarkEndpoint.cs | 21 | ||||
-rw-r--r-- | back-end/src/Endpoints/SiteLookupEndpoint.cs | 10 | ||||
-rw-r--r-- | back-end/src/SimpleBookmark.csproj | 8 | ||||
-rw-r--r-- | back-end/src/SimpleBookmarkEntry.cs | 30 |
5 files changed, 23 insertions, 54 deletions
diff --git a/back-end/src/Endpoints/BmAccountEndpoint.cs b/back-end/src/Endpoints/BmAccountEndpoint.cs index 24ddb90..81b2ff3 100644 --- a/back-end/src/Endpoints/BmAccountEndpoint.cs +++ b/back-end/src/Endpoints/BmAccountEndpoint.cs @@ -36,11 +36,12 @@ using VNLib.Plugins.Extensions.Loading; using VNLib.Plugins.Extensions.Validation; using VNLib.Plugins.Extensions.Loading.Users; using VNLib.Plugins.Extensions.Loading.Events; - -using SimpleBookmark.Model; +using VNLib.Plugins.Extensions.Loading.Routing; namespace SimpleBookmark.Endpoints { + [EndpointPath("{{path}}")] + [EndpointLogName("Accounts")] [ConfigurationName("registration")] internal sealed class BmAccountEndpoint : UnprotectedWebEndpoint { @@ -58,9 +59,6 @@ namespace SimpleBookmark.Endpoints public BmAccountEndpoint(PluginBase plugin, IConfigScope config) { - string path = config.GetRequiredProperty("path", p => p.GetString()!); - InitPathAndLog(path, plugin.Log); - //get setup mode and enabled startup arguments SetupMode = plugin.HostArgs.HasArgument("--setup"); Enabled = !plugin.HostArgs.HasArgument("--disable-registation"); diff --git a/back-end/src/Endpoints/BookmarkEndpoint.cs b/back-end/src/Endpoints/BookmarkEndpoint.cs index ae2932d..d76cb35 100644 --- a/back-end/src/Endpoints/BookmarkEndpoint.cs +++ b/back-end/src/Endpoints/BookmarkEndpoint.cs @@ -39,6 +39,7 @@ using VNLib.Plugins.Essentials.Accounts; using VNLib.Plugins.Essentials.Endpoints; using VNLib.Plugins.Essentials.Extensions; using VNLib.Plugins.Extensions.Loading; +using VNLib.Plugins.Extensions.Loading.Routing; using VNLib.Plugins.Extensions.Data.Extensions; using VNLib.Plugins.Extensions.Validation; @@ -47,25 +48,15 @@ using SimpleBookmark.Model; namespace SimpleBookmark.Endpoints { + [EndpointPath("{{path}}")] + [EndpointLogName("Bookmarks")] [ConfigurationName("bm_endpoint")] - internal sealed class BookmarkEndpoint : ProtectedWebEndpoint + internal sealed class BookmarkEndpoint(PluginBase plugin, IConfigScope config) : ProtectedWebEndpoint { private static readonly IValidator<BookmarkEntry> BmValidator = BookmarkEntry.GetValidator(); - private readonly BookmarkStore Bookmarks; - private readonly BookmarkStoreConfig BmConfig; - - public BookmarkEndpoint(PluginBase plugin, IConfigScope config) - { - string? path = config.GetRequiredProperty("path", p => p.GetString()!); - InitPathAndLog(path, plugin.Log); - - //Init bookmark store - Bookmarks = plugin.GetOrCreateSingleton<BookmarkStore>(); - - //Load config - BmConfig = config.GetRequiredProperty("config", p => p.Deserialize<BookmarkStoreConfig>()!); - } + private readonly BookmarkStore Bookmarks = plugin.GetOrCreateSingleton<BookmarkStore>(); + private readonly BookmarkStoreConfig BmConfig = config.GetRequiredProperty<BookmarkStoreConfig>("config"); ///<inheritdoc/> protected override async ValueTask<VfReturnType> GetAsync(HttpEntity entity) diff --git a/back-end/src/Endpoints/SiteLookupEndpoint.cs b/back-end/src/Endpoints/SiteLookupEndpoint.cs index effe6aa..f184ea9 100644 --- a/back-end/src/Endpoints/SiteLookupEndpoint.cs +++ b/back-end/src/Endpoints/SiteLookupEndpoint.cs @@ -28,11 +28,14 @@ using VNLib.Plugins.Essentials.Endpoints; using VNLib.Plugins.Essentials.Extensions; using VNLib.Plugins.Extensions.Loading; using VNLib.Plugins.Extensions.Validation; +using VNLib.Plugins.Extensions.Loading.Routing; using SimpleBookmark.PlatformFeatures.Curl; namespace SimpleBookmark.Endpoints { + [EndpointPath("{{path}}")] + [EndpointLogName("Site Lookup")] [ConfigurationName("curl")] internal sealed class SiteLookupEndpoint : ProtectedWebEndpoint { @@ -44,11 +47,8 @@ namespace SimpleBookmark.Endpoints public SiteLookupEndpoint(PluginBase plugin, IConfigScope config) { - string path = config.GetRequiredProperty("path", p => p.GetString()!); - InitPathAndLog(path, plugin.Log); - - string exePath = config.GetValueOrDefault("exe_path", p => p.GetString(), DefaultCurlExecName); - bool httspOnly = config.GetValueOrDefault("https_only", p => p.GetBoolean(), false); + string exePath = config.GetValueOrDefault("exe_path", DefaultCurlExecName); + bool httspOnly = config.GetValueOrDefault("https_only", false); //Optional extra arguments string[] extrArgs = config.GetValueOrDefault( diff --git a/back-end/src/SimpleBookmark.csproj b/back-end/src/SimpleBookmark.csproj index 382d141..ea8ade9 100644 --- a/back-end/src/SimpleBookmark.csproj +++ b/back-end/src/SimpleBookmark.csproj @@ -33,10 +33,10 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="VNLib.Plugins.Extensions.Data" Version="0.1.0-ci0064" /> - <PackageReference Include="VNLib.Plugins.Extensions.Loading" Version="0.1.0-ci0064" /> - <PackageReference Include="VNLib.Plugins.Extensions.Loading.Sql" Version="0.1.0-ci0064" /> - <PackageReference Include="VNLib.Plugins.Extensions.Validation" Version="0.1.0-ci0064" /> + <PackageReference Include="VNLib.Plugins.Extensions.Data" Version="0.1.0-ci0065" /> + <PackageReference Include="VNLib.Plugins.Extensions.Loading" Version="0.1.0-ci0065" /> + <PackageReference Include="VNLib.Plugins.Extensions.Loading.Sql" Version="0.1.0-ci0065" /> + <PackageReference Include="VNLib.Plugins.Extensions.Validation" Version="0.1.0-ci0065" /> <PackageReference Include="VNLib.Plugins.Extensions.VNCache" Version="0.1.0-ci0057" /> </ItemGroup> diff --git a/back-end/src/SimpleBookmarkEntry.cs b/back-end/src/SimpleBookmarkEntry.cs index 27813d7..85a52d3 100644 --- a/back-end/src/SimpleBookmarkEntry.cs +++ b/back-end/src/SimpleBookmarkEntry.cs @@ -22,9 +22,6 @@ */ using System; -using System.Linq; -using System.Text; -using System.Text.Json; using VNLib.Plugins; using VNLib.Utils.Logging; @@ -77,7 +74,7 @@ namespace SimpleBookmark @" ****************************************************************************** Simple-Bookmark - A linkding inspired, self hosted, bookmark manager - By Vaughn Nugent - vnpublic @proton.me + By Vaughn Nugent - vnpublic@proton.me https://www.vaughnnugent.com/resources/software License: GNU Affero General Public License v3.0 This application comes with ABSOLUTELY NO WARRANTY. @@ -85,27 +82,10 @@ namespace SimpleBookmark Documentation: https://www.vaughnnugent.com/resources/software/articles?tags=docs,_simple-bookmark GitHub: https://github.com/VnUgE/simple-bookmark {warning} - Your server is now running at the following locations:{0} -******************************************************************************"; - - string[] interfaces = HostConfig.GetProperty("virtual_hosts") - .EnumerateArray() - .Select(e => - { - JsonElement el = e.GetProperty("interface"); - string ipAddress = el.GetProperty("address").GetString()!; - int port = el.GetProperty("port").GetInt32(); - return $"{ipAddress}:{port}"; - }) - .ToArray(); - - StringBuilder sb = new(); - foreach (string intf in interfaces) - { - sb.Append("\n\t"); - sb.AppendLine(intf); - } +\******************************************************************************"; + + //See if setup mode is enabled bool setupMode = HostArgs.HasArgument("--setup") && !HostArgs.HasArgument("--disable-registation"); @@ -113,7 +93,7 @@ namespace SimpleBookmark ? "\nWARNING: This server is in setup mode. Account registation is open to all users.\n" : string.Empty; - Log.Information(template, warnMessage, sb); + Log.Information(template, warnMessage); } } } |