Files
Website/BlazorApp/Endpoints/DeveloperEndpoints.cs
SysAdmin 21c07adf54 feat(developers): add developer program signup with SilverDESK integration
Add developer application page with form submission that creates tickets
in SilverDESK. Includes provisioning service scaffolding for Mattermost,
Mailcow, and Gitea account creation. Fixes API key header casing
(X-API-Key) and ticket payload to match SilverDESK's CreateTicketDto
contract.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 20:51:36 +00:00

44 lines
1.5 KiB
C#

using SilverLabs.Website.Models;
using SilverLabs.Website.Services;
namespace SilverLabs.Website.Endpoints;
public static class DeveloperEndpoints
{
public static void MapDeveloperEndpoints(this WebApplication app)
{
var group = app.MapGroup("/api/developers");
group.MapPost("/apply", async (DeveloperApplication application, DeveloperApplicationService service) =>
{
var (success, message) = await service.SubmitApplicationAsync(application);
return success
? Results.Ok(new { message })
: Results.Problem(message, statusCode: 502);
});
group.MapPost("/approve/{ticketId:int}", async (
int ticketId,
ApproveRequest request,
ProvisioningService service,
HttpContext context,
IConfiguration config) =>
{
var apiKey = context.Request.Headers["X-Api-Key"].FirstOrDefault();
var expectedKey = config["AdminApiKey"];
if (string.IsNullOrEmpty(expectedKey) || apiKey != expectedKey)
return Results.Unauthorized();
var (success, message) = await service.ApproveApplicationAsync(
ticketId, request.Username, request.Email, request.FullName);
return success
? Results.Ok(new { message })
: Results.Problem(message, statusCode: 502);
});
}
}
public record ApproveRequest(string Username, string Email, string FullName);