petite factorisation

This commit is contained in:
Paul Schneider 2026-06-20 18:43:01 +01:00
commit b2a35b60ce
9 changed files with 26 additions and 32 deletions

View file

@ -0,0 +1,10 @@
namespace Yavsc.Blogs;
public static class Constants
{
public const string AdminRole = "Admin";
public const string ModeratorRole = "Moderator";
public const string UserRole = "User";
public const string APIPrefix = "api/v1";
}

View file

@ -1,17 +1,15 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Yavsc.Models;
using Yavsc.Models.Blog;
using Yavsc.Server.Exceptions;
using Yavsc.Server.Helpers;
using static Yavsc.Blogs.Constants;
namespace Yavsc.Blogs.Controllers
{
[Authorize("BlogScope")]
[Produces("application/json")]
[Route("api/blog")]
[Route(APIPrefix + "/blog")]
public class BlogApiController : Controller
{

View file

@ -6,10 +6,11 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Yavsc.Models;
using Yavsc.Models.Blog;
using static Yavsc.Blogs.Constants;
namespace Yavsc.Blogs.Controllers
{
[Produces("application/json")]
[Route("api/blogtags")]
[Route(APIPrefix + "/blogtags")]
public class BlogTagsApiController : Controller
{
private readonly ApplicationDbContext _context;

View file

@ -2,17 +2,16 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Models.Blog;
using Yavsc.Server.Helpers;
using static Yavsc.Blogs.Constants;
namespace Yavsc.Blogs.Controllers
{
[Authorize]
[Produces("application/json")]
[Route("api/blogcomments")]
[Route(APIPrefix + "/blogcomments")]
public class CommentsApiController : Controller
{
private readonly ApplicationDbContext _context;

View file

@ -2,6 +2,7 @@
using System.Security.Claims;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using static Yavsc.Blogs.Constants;
namespace Yavsc.Blogs.Controllers
{
@ -12,7 +13,7 @@ namespace Yavsc.Blogs.Controllers
using Yavsc.Abstract.Helpers;
using Yavsc.Server.Models.FileSystem;
[Authorize,Route("api/fs")]
[Authorize,Route(APIPrefix + "/fs")]
public partial class FileSystemApiController : Controller
{
readonly ApplicationDbContext dbContext;

View file

@ -9,10 +9,11 @@ using Yavsc.Models.Messaging;
using Yavsc.Services;
using Microsoft.AspNetCore.SignalR;
using Yavsc.Server.Helpers;
using static Yavsc.Blogs.Constants;
namespace Yavsc.Blogs.Controllers
{
[Authorize, Route("api/stream")]
[Authorize, Route(APIPrefix + "/stream")]
public partial class FileSystemStreamController : Controller
{
private readonly ILogger logger;

View file

@ -1,19 +1,15 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using static Yavsc.Blogs.Constants;
namespace Yavsc.Blogs.Controllers
{
using System.Security.Claims;
using Microsoft.EntityFrameworkCore;
using Models;
using Yavsc.Helpers;
using Yavsc.Models.Blog;
using Yavsc.Server.Helpers;
[Produces("application/json")]
[Route("~/api/PostTagsApi")]
[Route(APIPrefix + "/PostTagsApi")]
public class PostTagsApiController : Controller
{
private ApplicationDbContext _context;

View file

@ -1,17 +1,16 @@
using Microsoft.AspNetCore.Mvc;
using Yavsc.Models;
using static Yavsc.Blogs.Constants;
namespace Yavsc.Controllers
{
using System.Security.Claims;
using Microsoft.EntityFrameworkCore;
using Models.Relationship;
using Yavsc.Helpers;
using Yavsc.Server.Helpers;
[Produces("application/json")]
[Route("api/TagsApi")]
[Route(APIPrefix + "/TagsApi")]
public class TagsApiController : Controller
{
private ApplicationDbContext _context;

View file

@ -1,15 +1,3 @@
/*
Copyright (c) 2024 HigginsSoft, Alexander Higgins - https://github.com/alexhiggins732/
Copyright (c) 2018, Brock Allen & Dominick Baier. All rights reserved.
Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
Source code and license this software can be found
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
*/
using IdentityModel;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@ -53,7 +41,8 @@ internal class Program
// DbContextBuilder
services.AddDbContext<ApplicationDbContext>(options =>
options.UseNpgsql(builder.Configuration.GetConnectionString(YavscConstants.YavscConnectionStringName)));
options.UseNpgsql(builder.Configuration.GetConnectionString(
YavscConstants.YavscConnectionStringName)));
// other services
services