Files
flatrender/services/content/FlatRender.ContentSvc/Controllers/TemplatesController.cs
T
soroush.asadi 90ac0b81d1 feat: V2 microservices stack — backend services, gateway, JWT auth
Add full V2 architecture: identity, content, studio (.NET 10) and file,
render, notification, gateway (Go) services with vendored deps, plus DB
migrations, event/API contracts, and an init-db script.

Wire the Next.js frontend to the gateway: server-side JWT auth routes
(login/register/refresh/logout/me), gateway fetch helper, and session/
cookie/jwt helpers under src/lib.

Containerize the stack via docker-compose.v2.yml and per-service
Dockerfiles. Base images resolve through a Nexus mirror (Docker Hub) and
MCR directly; npm/NuGet pull from Nexus groups. Self-host fonts via
next/font/local to avoid Google Fonts (geo-blocked).

Add CI workflow and ignore .env.v2, *.stackdump, and .NET bin/obj.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 23:29:31 +03:30

71 lines
2.4 KiB
C#

using FlatRender.ContentSvc.Application.Services;
using FlatRender.ContentSvc.Models.Requests;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace FlatRender.ContentSvc.Controllers;
[ApiController]
[Route("v1/templates")]
public class TemplatesController(TemplateService svc) : ControllerBase
{
// ── Containers ────────────────────────────────────────────────────────────
[HttpGet]
public async Task<IActionResult> ListContainers([FromQuery] ContainerListRequest req) =>
Ok(await svc.GetContainersAsync(req));
[HttpGet("{slug}")]
public async Task<IActionResult> GetContainer(string slug)
{
await svc.IncrementContainerViewAsync(
(await svc.GetContainerBySlugAsync(slug)).Id);
return Ok(await svc.GetContainerBySlugAsync(slug));
}
[Authorize(Roles = "Admin")]
[HttpPost]
public async Task<IActionResult> CreateContainer([FromBody] CreateContainerRequest req) =>
Ok(await svc.CreateContainerAsync(req));
[Authorize(Roles = "Admin")]
[HttpPut("{id:guid}")]
public async Task<IActionResult> UpdateContainer(Guid id, [FromBody] UpdateContainerRequest req) =>
Ok(await svc.UpdateContainerAsync(id, req));
[Authorize(Roles = "Admin")]
[HttpDelete("{id:guid}")]
public async Task<IActionResult> DeleteContainer(Guid id)
{
await svc.DeleteContainerAsync(id);
return NoContent();
}
}
[ApiController]
[Route("v1/projects")]
public class ProjectsController(TemplateService svc) : ControllerBase
{
[HttpGet("{id:guid}")]
public async Task<IActionResult> GetProject(Guid id) =>
Ok(await svc.GetProjectDetailAsync(id));
[Authorize(Roles = "Admin")]
[HttpPost]
public async Task<IActionResult> CreateProject([FromBody] CreateProjectRequest req) =>
Ok(await svc.CreateProjectAsync(req));
[Authorize(Roles = "Admin")]
[HttpPut("{id:guid}")]
public async Task<IActionResult> UpdateProject(Guid id, [FromBody] UpdateProjectRequest req) =>
Ok(await svc.UpdateProjectAsync(id, req));
[Authorize(Roles = "Admin")]
[HttpDelete("{id:guid}")]
public async Task<IActionResult> DeleteProject(Guid id)
{
await svc.DeleteProjectAsync(id);
return NoContent();
}
}