Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/apps/api/Program.cs
diff options
context:
space:
mode:
authorLeitwolf112026-10-29 09:53:57 +0300
committerLeitwolf112026-10-29 09:53:57 +0300
commit58fa0d19d223aaebf9973ebd446c4bb855351ef9 (patch)
tree6fce1c3d9f2255e80ec92c3040e7280c0ce131ae /apps/api/Program.cs
parentf22418235a0a87bc05b3bf9079fcdefba002d3b2 (diff)
downloadprogmaweb-58fa0d19d223aaebf9973ebd446c4bb855351ef9.tar.gz
Add the Tazel plugin catalog of ViGet to the API
ViGet opens in stages: first only Progmasoft publishes Tazel plugins, later every account. This adds the catalog and the server-side publishing for the first stage; nothing publishes through the API yet. - ViGet/: the catalog of Tazel plugins (in memory, or in PostgreSQL beside the accounts with its own numbered schema steps), the descriptor read from the JAR (META-INF/tazel-plugin.properties, with a reader of the Java properties format, and the ProjectPlugin service entry), and publishing: the publisher must be in ViGet:TazelPublishers (Progmasoft for now) and an existing account of that exact name, a version is never replaced, names that differ only in letter case are refused, and ViGet needs a description, an author and a license. The JAR is kept at dslplugins/tazel/<Publisher>/<Name>/<Version>/<Name>-<Version>.jar below ViGet:ArtifactRoot. - Read endpoints under /api/v1/viget/dslplugins/tazel: the list, a plugin, and index.json, the index Tazel reads. - 'viget publish-tazel-plugin <jar>' and 'viget yank-tazel-plugin' run with the configuration of the service instead of the service. - The account store can find an account by name. The pages, the Nginx routes and the deployment follow.
Diffstat (limited to 'apps/api/Program.cs')
-rw-r--r--apps/api/Program.cs16
1 files changed, 15 insertions, 1 deletions
diff --git a/apps/api/Program.cs b/apps/api/Program.cs
index 476cbdb..873c120 100644
--- a/apps/api/Program.cs
+++ b/apps/api/Program.cs
@@ -9,8 +9,12 @@ using Microsoft.AspNetCore.HttpOverrides;
using Progmasoft.Progmaweb.Api.Accounts;
using Progmasoft.OAuth;
using Progmasoft.Progmaweb.Api.Security;
+using Progmasoft.Progmaweb.Api.ViGet;
-WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
+// `viget ...` runs a command of ViGet with the configuration of the service instead of the service itself; its
+// arguments are not configuration.
+bool vigetCommand = ViGetCommand.IsCommand(args);
+WebApplicationBuilder builder = WebApplication.CreateBuilder(vigetCommand ? [] : args);
builder.Services.Configure<AccountSessionOptions>(builder.Configuration.GetSection(AccountSessionOptions.SectionName));
builder.Services.AddSingleton(TimeProvider.System);
@@ -21,6 +25,8 @@ builder.Services.AddSingleton<AccountService>();
builder.Services.AddSingleton<SessionService>();
// Progmasoft OAuth, the OAuth 2.1 and OpenID Connect provider on its own host; see OAuth/OAuthRegistration.cs.
builder.Services.AddProgmasoftOAuth(builder.Configuration, accountStore, builder.Environment.IsProduction());
+// ViGet: the Tazel plugin catalog beside the accounts; see ViGet/ViGetEndpoints.cs.
+builder.Services.AddViGet(builder.Configuration, accountStore);
builder.Services.AddAuthorization();
AuthenticationBuilder authentication = builder.Services
.AddAuthentication()
@@ -103,6 +109,13 @@ builder.WebHost.ConfigureKestrel(options => options.Limits.MaxRequestBodySize =
WebApplication app = builder.Build();
+if (vigetCommand)
+{
+ Environment.ExitCode = await ViGetCommand.RunAsync(
+ app.Services, args[1..], Console.Out, Console.Error, CancellationToken.None);
+ return;
+}
+
if (accountStore is AccountStoreKind.Memory)
{
AccountStoreRegistration.WarnThatAccountsAreInMemory(app.Logger);
@@ -134,6 +147,7 @@ app.MapGet("/api/v1/status", () => Results.Ok(new
}));
app.MapAccountEndpoints();
app.MapProgmasoftOAuth();
+app.MapViGetEndpoints();
app.Run();