aboutsummaryrefslogtreecommitdiff
path: root/back-end
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2024-06-04 15:59:02 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2024-06-04 15:59:02 -0400
commit71b581e006fda94aa675b7df9a7fbfe35d748b48 (patch)
tree3ae4832021a63249f53bd68b28759cd496397784 /back-end
parent28e67e58208a13bd5f9afb19b6a2e57f904eec80 (diff)
Squashed commit of the following:v0.1.6
commit bbe3b9b80db68cf86e26bd2e40a07c1650031224 Author: vnugent <public@vaughnnugent.com> Date: Tue Jun 4 15:54:42 2024 -0400 ignore npm version bump errors for build commit 45816924e5a47710a6bc4ed0d59ea81a48eddd1e Author: vnugent <public@vaughnnugent.com> Date: Tue Jun 4 15:30:35 2024 -0400 project version in ui commit 03357c9f7b7fa389d2d426e95d9854b7b04623f9 Author: vnugent <public@vaughnnugent.com> Date: Tue Jun 4 12:59:30 2024 -0400 chore: Essentials upstream update commit b6d292014700d05a93aa4e486baedf37656f464a Author: vnugent <public@vaughnnugent.com> Date: Thu May 23 19:09:28 2024 -0400 docs: Update readme instructions commit 5b6b4c06bc4b974e1839ca47c91dd6c903f119fd Author: vnugent <public@vaughnnugent.com> Date: Thu May 23 18:17:56 2024 -0400 build(server): Update Docker config to support new vars commit c7c9e8a441e99e1dc79e2a690d83281af463d817 Author: vnugent <public@vaughnnugent.com> Date: Thu May 23 17:40:09 2024 -0400 update backend deps commit 06eb12d107f2605cae0f14884de04058c02d29f7 Author: vnugent <public@vaughnnugent.com> Date: Thu May 23 17:38:22 2024 -0400 chore: package updates and verify commit c8e3ca86be45be05c1f76a7dd808275a1afaccb0 Author: vnugent <public@vaughnnugent.com> Date: Thu May 16 17:10:27 2024 -0400 chore: Remove unused cache stuff commit ba2ee1073a5042bda0afc2b56233fe99d491b39d Merge: e6b4e60 28e67e5 Author: vnugent <public@vaughnnugent.com> Date: Wed May 15 18:08:48 2024 -0400 Merge branch 'master' into develop commit e6b4e605622f2b323fd3fe0aa01000f3986e3bba Author: vnugent <public@vaughnnugent.com> Date: Wed May 15 16:35:06 2024 -0400 build: Fix ssl container dir, and certificate automation commit a710553aa5c0484b6934b8a5d4d16b1eb3ff2a88 Author: vnugent <public@vaughnnugent.com> Date: Wed May 15 15:37:53 2024 -0400 ci: Admin form clear, polish build and release taskfiels commit 372eb6a32a9891afb5035caa0805e8ed878416d8 Author: vnugent <public@vaughnnugent.com> Date: Tue May 14 22:27:10 2024 -0400 default read secret pepper from file for bare-metal builds commit 1b7270b40b65ef089bf40a14065227f742b8507e Author: vnugent <public@vaughnnugent.com> Date: Tue May 14 21:52:03 2024 -0400 chore: make container slightly easier to setup commit 2deda50a167286bc93fd3871a1fd6dbf9f43c81f Merge: 28f0f77 96ae7b0 Author: vnugent <public@vaughnnugent.com> Date: Sun Apr 28 10:54:09 2024 -0400 Merge branch 'master' into develop commit 28f0f774da975c04271445761b2de31aecf969ff Author: vnugent <public@vaughnnugent.com> Date: Sat Apr 27 23:11:48 2024 -0400 Add --no-cache arg to build image args commit 22a1f5d374ec1a487944c6303066d0f15617cb12 Author: vnugent <public@vaughnnugent.com> Date: Sat Apr 27 18:47:25 2024 -0400 fix: Upstream patch missing ! in middlware commit f40ca2d4c26f81276d58760152592a918bf3cd87 Author: vnugent <public@vaughnnugent.com> Date: Sat Apr 27 18:36:01 2024 -0400 chore: package updates commit d7a3c957467e65ea7176170fba3c280ac18ac17e Author: vnugent <public@vaughnnugent.com> Date: Sun Apr 21 12:02:57 2024 -0400 chore: Package updates and minor QOL patches commit 97a5bded5122708cf39d0e86bc24a5f31755bdd1 Merge: 56e0a38 5877c86 Author: vnugent <public@vaughnnugent.com> Date: Tue Apr 9 17:38:02 2024 -0400 Merge branch 'master' into develop commit 56e0a38b2ca246e8beeaef3c6c4b9c0ce7d0f09b Author: vnugent <public@vaughnnugent.com> Date: Tue Apr 9 17:35:13 2024 -0400 chore(app): Update deps, login spinner, curl msg, view prep commit 0945210c0492dd8a8de99ccd8e5e66cf05e3a1c1 Merge: 24fac82 3c15d54 Author: vnugent <public@vaughnnugent.com> Date: Tue Apr 2 14:58:59 2024 -0400 Merge branch 'master' into develop commit 24fac82efe9e5c18e86ed535678640e7401472db Author: vnugent <public@vaughnnugent.com> Date: Tue Apr 2 14:54:20 2024 -0400 ci: Configure manual dep versions commit d2ae31ec919d72e66d8b40db8394b55efd6ea6d3 Author: vnugent <public@vaughnnugent.com> Date: Sun Mar 31 22:19:53 2024 -0400 ci: Native compression support for win commit fa7fdef79c6d468022b77f81314ac129fe0cdc32 Merge: 308092d a01220a Author: vnugent <public@vaughnnugent.com> Date: Wed Mar 13 21:26:55 2024 -0400 Merge branch 'master' into develop commit 308092d6d743d0ba8f7ca86fd77e9c837dc46e88 Merge: 48637a8 9134093 Author: vnugent <public@vaughnnugent.com> Date: Wed Mar 13 21:01:02 2024 -0400 Merge branch 'master' into develop commit 48637a8781fc951c307216f604fc1610e68691c3 Merge: 1e08c6d e326736 Author: vnugent <public@vaughnnugent.com> Date: Wed Mar 13 16:20:35 2024 -0400 Merge branch 'master' into develop commit 1e08c6d2112459dc02a0ab873123c4a363b01d21 Author: vnugent <public@vaughnnugent.com> Date: Wed Mar 13 16:17:58 2024 -0400 ci: verified container build ready for next release commit 85a1e5b7cc5c99e97a2d4e99bbceb0d2139742ff Author: vnugent <public@vaughnnugent.com> Date: Tue Mar 12 22:05:16 2024 -0400 ci: exciting bare-metal build process, os support, smaller packages commit 748cdbf4880d830fd794e92856e8c35a46e4f884 Author: vnugent <public@vaughnnugent.com> Date: Mon Mar 11 21:21:18 2024 -0400 feat(app): #1 update libs & add curl support
Diffstat (limited to 'back-end')
-rw-r--r--back-end/src/Cache/MemPackCacheSerializer.cs34
-rw-r--r--back-end/src/Cache/ResultCacheEntry.cs44
-rw-r--r--back-end/src/Cache/SearchResultCache.cs111
-rw-r--r--back-end/src/Endpoints/BookmarkEndpoint.cs31
-rw-r--r--back-end/src/SimpleBookmark.csproj11
5 files changed, 26 insertions, 205 deletions
diff --git a/back-end/src/Cache/MemPackCacheSerializer.cs b/back-end/src/Cache/MemPackCacheSerializer.cs
deleted file mode 100644
index f1ffa88..0000000
--- a/back-end/src/Cache/MemPackCacheSerializer.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (C) 2024 Vaughn Nugent
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Affero General Public License as
-// published by the Free Software Foundation, either version 3 of the
-// License, or (at your option) any later version.
-//
-// This program 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 Affero General Public License for more details.
-//
-// You should have received a copy of the GNU Affero General Public License
-// along with this program. If not, see <https://www.gnu.org/licenses/>.
-
-
-using System;
-using System.Buffers;
-
-using MemoryPack;
-
-using VNLib.Data.Caching;
-
-namespace SimpleBookmark.Cache
-{
- internal sealed class MemPackCacheSerializer(MemoryPackSerializerOptions? options) : ICacheObjectSerializer, ICacheObjectDeserializer
- {
- ///<inheritdoc/>
- public T? Deserialize<T>(ReadOnlySpan<byte> objectData) => MemoryPackSerializer.Deserialize<T>(objectData, options);
-
- ///<inheritdoc/>
- public void Serialize<T>(T obj, IBufferWriter<byte> finiteWriter) => MemoryPackSerializer.Serialize(finiteWriter, obj, options);
- }
-}
diff --git a/back-end/src/Cache/ResultCacheEntry.cs b/back-end/src/Cache/ResultCacheEntry.cs
deleted file mode 100644
index 3e23042..0000000
--- a/back-end/src/Cache/ResultCacheEntry.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (C) 2024 Vaughn Nugent
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Affero General Public License as
-// published by the Free Software Foundation, either version 3 of the
-// License, or (at your option) any later version.
-//
-// This program 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 Affero General Public License for more details.
-//
-// You should have received a copy of the GNU Affero General Public License
-// along with this program. If not, see <https://www.gnu.org/licenses/>.
-
-using System;
-using System.Buffers;
-using System.Runtime.InteropServices;
-using System.Text.Json.Serialization;
-
-using MemoryPack;
-
-namespace SimpleBookmark.Cache
-{
- [MemoryPackable]
- internal partial class ResultCacheEntry : IDisposable
- {
- [MemoryPoolFormatter<byte>]
- public Memory<byte> Payload { get; set; }
-
- [JsonPropertyName("created")]
- public DateTime Created { get; set; }
-
- public void Dispose()
- {
- //Return the array back to the pool
- if (MemoryMarshal.TryGetArray(Payload, out ArraySegment<byte> segment) && segment.Array is { Length: > 0 })
- {
- ArrayPool<byte>.Shared.Return(segment.Array);
- Payload = default;
- }
- }
- }
-}
diff --git a/back-end/src/Cache/SearchResultCache.cs b/back-end/src/Cache/SearchResultCache.cs
deleted file mode 100644
index c7a263a..0000000
--- a/back-end/src/Cache/SearchResultCache.cs
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright (C) 2024 Vaughn Nugent
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Affero General Public License as
-// published by the Free Software Foundation, either version 3 of the
-// License, or (at your option) any later version.
-//
-// This program 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 Affero General Public License for more details.
-//
-// You should have received a copy of the GNU Affero General Public License
-// along with this program. If not, see <https://www.gnu.org/licenses/>.
-
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-
-using VNLib.Net.Http;
-using VNLib.Data.Caching;
-using VNLib.Plugins;
-using VNLib.Plugins.Extensions.Loading;
-using VNLib.Plugins.Extensions.VNCache;
-using VNLib.Plugins.Extensions.VNCache.DataModel;
-
-namespace SimpleBookmark.Cache
-{
- [ConfigurationName("search_cache", Required = false)]
- internal sealed class SearchResultCache
- {
- private readonly IEntityCache<ResultCacheEntry>? _cache;
-
- /// <summary>
- /// Gets a value that indicates if the configuration enabled result caching
- /// </summary>
- public bool IsEnabled => _cache != null;
-
- public SearchResultCache(PluginBase plugin) : this(plugin, null)
- { }
-
- public SearchResultCache(PluginBase plugin, IConfigScope? config)
- {
- string? cachePrefix = config?.GetRequiredProperty("cachePrefix", p => p.GetString()!);
- bool isEnabled = config?.GetRequiredProperty("enabled", p => p.GetBoolean()) ?? true;
-
- if (!isEnabled)
- {
- return;
- }
-
- IGlobalCacheProvider? cache = plugin.GetDefaultGlobalCache();
- if (cache != null)
- {
- if (cachePrefix != null)
- {
- _cache = cache.GetPrefixedCache(cachePrefix)
- .CreateEntityCache<ResultCacheEntry>(
- new MemPackCacheSerializer(null),
- new MemPackCacheSerializer(null)
- );
- }
- else
- {
- //non-prefixed cache
- _cache = cache.CreateEntityCache<ResultCacheEntry>(
- new MemPackCacheSerializer(null),
- new MemPackCacheSerializer(null)
- );
- }
- }
- }
-
- public async Task<IMemoryResponseReader?> GetCachedResultAsync(string[] keys, CancellationToken cancellation)
- {
- ResultCacheEntry? entry = await _cache!.GetAsync($"{keys}", cancellation);
- return entry is null ? null : new ResultResponseReader(entry);
- }
-
- public Task StoreResultAsync(Memory<byte> data, string[] keys, CancellationToken cancellation)
- {
- //Init new entry
- ResultCacheEntry entry = new()
- {
- Payload = data,
- Created = DateTime.UtcNow
- };
-
- return _cache!.UpsertAsync($"{keys}", entry, cancellation);
- }
-
- public Task DeleteEntry(string[] keys, CancellationToken cancellation) => _cache!.RemoveAsync($"{keys}", cancellation);
-
- private sealed class ResultResponseReader(ResultCacheEntry entry) : IMemoryResponseReader
- {
- private int _position;
-
- ///<inheritdoc/>
- public int Remaining => entry.Payload.Length - _position;
-
- ///<inheritdoc/>
- public void Advance(int written) => _position += written;
-
- ///<inheritdoc/>
- public void Close() => entry.Dispose();
-
- ///<inheritdoc/>
- public ReadOnlyMemory<byte> GetMemory() => entry.Payload.Slice(_position);
- }
- }
-}
diff --git a/back-end/src/Endpoints/BookmarkEndpoint.cs b/back-end/src/Endpoints/BookmarkEndpoint.cs
index 19f5118..ae2932d 100644
--- a/back-end/src/Endpoints/BookmarkEndpoint.cs
+++ b/back-end/src/Endpoints/BookmarkEndpoint.cs
@@ -131,7 +131,13 @@ namespace SimpleBookmark.Endpoints
{
//Get the collection of bookmarks
List<BookmarkEntry> list = Bookmarks.ListRental.Rent();
- await Bookmarks.GetUserPageAsync(list, entity.Session.UserID, 0, (int)BmConfig.PerPersonQuota);
+
+ await Bookmarks.GetUserPageAsync(
+ collection: list,
+ userId: entity.Session.UserID,
+ page: 0,
+ limit: (int)BmConfig.PerPersonQuota
+ );
//Alloc memory stream for output
VnMemoryStream output = new(MemoryUtil.Shared, 16 * 1024, false);
@@ -205,13 +211,13 @@ namespace SimpleBookmark.Endpoints
//Get bookmarks
BookmarkEntry[] bookmarks = await Bookmarks.SearchBookmarksAsync(
- entity.Session.UserID,
+ userId : entity.Session.UserID,
query,
tags,
(int)limit,
(int)offset,
- entity.EventCancellation
- );
+ cancellation: entity.EventCancellation
+ );
//Return result
return VirtualOkJson(entity, bookmarks);
@@ -248,11 +254,11 @@ namespace SimpleBookmark.Endpoints
* and the entry does not already exist by the desired url.
*/
int result = await Bookmarks.AddSingleIfNotExists(
- entity.Session.UserID,
- newBookmark,
- entity.RequestedTimeUtc.DateTime,
- BmConfig.PerPersonQuota,
- entity.EventCancellation
+ userId: entity.Session.UserID,
+ entry: newBookmark,
+ now: entity.RequestedTimeUtc.DateTime,
+ maxRecords: BmConfig.PerPersonQuota,
+ cancellation: entity.EventCancellation
);
if (webm.Assert(result > -1, "You have reached your bookmark quota"))
@@ -386,7 +392,12 @@ namespace SimpleBookmark.Endpoints
try
{
//Try to update the records
- ERRNO result = await Bookmarks.AddBulkAsync(sanitized, entity.Session.UserID, entity.RequestedTimeUtc, entity.EventCancellation);
+ ERRNO result = await Bookmarks.AddBulkAsync(
+ bookmarks: sanitized,
+ userId: entity.Session.UserID,
+ now: entity.RequestedTimeUtc,
+ cancellation: entity.EventCancellation
+ );
webm.Result = $"Successfully added {result} of {batch.Length} bookmarks";
webm.Success = true;
diff --git a/back-end/src/SimpleBookmark.csproj b/back-end/src/SimpleBookmark.csproj
index fc9b46a..382d141 100644
--- a/back-end/src/SimpleBookmark.csproj
+++ b/back-end/src/SimpleBookmark.csproj
@@ -33,12 +33,11 @@
</ItemGroup>
<ItemGroup>
- <PackageReference Include="MemoryPack" Version="1.21.1" />
- <PackageReference Include="VNLib.Plugins.Extensions.Data" Version="0.1.0-ci0063" />
- <PackageReference Include="VNLib.Plugins.Extensions.Loading" Version="0.1.0-ci0063" />
- <PackageReference Include="VNLib.Plugins.Extensions.Loading.Sql" Version="0.1.0-ci0063" />
- <PackageReference Include="VNLib.Plugins.Extensions.Validation" Version="0.1.0-ci0063" />
- <PackageReference Include="VNLib.Plugins.Extensions.VNCache" Version="0.1.0-ci0056" />
+ <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.VNCache" Version="0.1.0-ci0057" />
</ItemGroup>
<ItemGroup>