petite factorisation
This commit is contained in:
parent
fd129f19f5
commit
b2a35b60ce
9 changed files with 26 additions and 32 deletions
10
src/Yavsc.Blogs/Constants.cs
Normal file
10
src/Yavsc.Blogs/Constants.cs
Normal 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";
|
||||||
|
}
|
||||||
|
|
@ -1,17 +1,15 @@
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Yavsc.Models;
|
|
||||||
using Yavsc.Models.Blog;
|
using Yavsc.Models.Blog;
|
||||||
using Yavsc.Server.Exceptions;
|
using Yavsc.Server.Exceptions;
|
||||||
using Yavsc.Server.Helpers;
|
using Yavsc.Server.Helpers;
|
||||||
|
using static Yavsc.Blogs.Constants;
|
||||||
|
|
||||||
namespace Yavsc.Blogs.Controllers
|
namespace Yavsc.Blogs.Controllers
|
||||||
{
|
{
|
||||||
[Authorize("BlogScope")]
|
[Authorize("BlogScope")]
|
||||||
[Produces("application/json")]
|
[Produces("application/json")]
|
||||||
[Route("api/blog")]
|
[Route(APIPrefix + "/blog")]
|
||||||
|
|
||||||
public class BlogApiController : Controller
|
public class BlogApiController : Controller
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,11 @@ using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Yavsc.Models;
|
using Yavsc.Models;
|
||||||
using Yavsc.Models.Blog;
|
using Yavsc.Models.Blog;
|
||||||
|
using static Yavsc.Blogs.Constants;
|
||||||
namespace Yavsc.Blogs.Controllers
|
namespace Yavsc.Blogs.Controllers
|
||||||
{
|
{
|
||||||
[Produces("application/json")]
|
[Produces("application/json")]
|
||||||
[Route("api/blogtags")]
|
[Route(APIPrefix + "/blogtags")]
|
||||||
public class BlogTagsApiController : Controller
|
public class BlogTagsApiController : Controller
|
||||||
{
|
{
|
||||||
private readonly ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,16 @@
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
|
||||||
using Yavsc.Helpers;
|
|
||||||
using Yavsc.Models;
|
using Yavsc.Models;
|
||||||
using Yavsc.Models.Blog;
|
using Yavsc.Models.Blog;
|
||||||
using Yavsc.Server.Helpers;
|
using Yavsc.Server.Helpers;
|
||||||
|
using static Yavsc.Blogs.Constants;
|
||||||
|
|
||||||
namespace Yavsc.Blogs.Controllers
|
namespace Yavsc.Blogs.Controllers
|
||||||
{
|
{
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[Produces("application/json")]
|
[Produces("application/json")]
|
||||||
[Route("api/blogcomments")]
|
[Route(APIPrefix + "/blogcomments")]
|
||||||
public class CommentsApiController : Controller
|
public class CommentsApiController : Controller
|
||||||
{
|
{
|
||||||
private readonly ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using static Yavsc.Blogs.Constants;
|
||||||
|
|
||||||
namespace Yavsc.Blogs.Controllers
|
namespace Yavsc.Blogs.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -12,7 +13,7 @@ namespace Yavsc.Blogs.Controllers
|
||||||
using Yavsc.Abstract.Helpers;
|
using Yavsc.Abstract.Helpers;
|
||||||
using Yavsc.Server.Models.FileSystem;
|
using Yavsc.Server.Models.FileSystem;
|
||||||
|
|
||||||
[Authorize,Route("api/fs")]
|
[Authorize,Route(APIPrefix + "/fs")]
|
||||||
public partial class FileSystemApiController : Controller
|
public partial class FileSystemApiController : Controller
|
||||||
{
|
{
|
||||||
readonly ApplicationDbContext dbContext;
|
readonly ApplicationDbContext dbContext;
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,11 @@ using Yavsc.Models.Messaging;
|
||||||
using Yavsc.Services;
|
using Yavsc.Services;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using Yavsc.Server.Helpers;
|
using Yavsc.Server.Helpers;
|
||||||
|
using static Yavsc.Blogs.Constants;
|
||||||
|
|
||||||
namespace Yavsc.Blogs.Controllers
|
namespace Yavsc.Blogs.Controllers
|
||||||
{
|
{
|
||||||
[Authorize, Route("api/stream")]
|
[Authorize, Route(APIPrefix + "/stream")]
|
||||||
public partial class FileSystemStreamController : Controller
|
public partial class FileSystemStreamController : Controller
|
||||||
{
|
{
|
||||||
private readonly ILogger logger;
|
private readonly ILogger logger;
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,15 @@
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using static Yavsc.Blogs.Constants;
|
||||||
|
|
||||||
namespace Yavsc.Blogs.Controllers
|
namespace Yavsc.Blogs.Controllers
|
||||||
{
|
{
|
||||||
using System.Security.Claims;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Models;
|
using Models;
|
||||||
using Yavsc.Helpers;
|
|
||||||
using Yavsc.Models.Blog;
|
using Yavsc.Models.Blog;
|
||||||
using Yavsc.Server.Helpers;
|
using Yavsc.Server.Helpers;
|
||||||
|
|
||||||
[Produces("application/json")]
|
[Produces("application/json")]
|
||||||
[Route("~/api/PostTagsApi")]
|
[Route(APIPrefix + "/PostTagsApi")]
|
||||||
public class PostTagsApiController : Controller
|
public class PostTagsApiController : Controller
|
||||||
{
|
{
|
||||||
private ApplicationDbContext _context;
|
private ApplicationDbContext _context;
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,16 @@
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Yavsc.Models;
|
using Yavsc.Models;
|
||||||
|
using static Yavsc.Blogs.Constants;
|
||||||
|
|
||||||
namespace Yavsc.Controllers
|
namespace Yavsc.Controllers
|
||||||
{
|
{
|
||||||
using System.Security.Claims;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Models.Relationship;
|
using Models.Relationship;
|
||||||
using Yavsc.Helpers;
|
|
||||||
using Yavsc.Server.Helpers;
|
using Yavsc.Server.Helpers;
|
||||||
|
|
||||||
[Produces("application/json")]
|
[Produces("application/json")]
|
||||||
[Route("api/TagsApi")]
|
[Route(APIPrefix + "/TagsApi")]
|
||||||
public class TagsApiController : Controller
|
public class TagsApiController : Controller
|
||||||
{
|
{
|
||||||
private ApplicationDbContext _context;
|
private ApplicationDbContext _context;
|
||||||
|
|
|
||||||
|
|
@ -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 IdentityModel;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
@ -53,7 +41,8 @@ internal class Program
|
||||||
|
|
||||||
// DbContextBuilder
|
// DbContextBuilder
|
||||||
services.AddDbContext<ApplicationDbContext>(options =>
|
services.AddDbContext<ApplicationDbContext>(options =>
|
||||||
options.UseNpgsql(builder.Configuration.GetConnectionString(YavscConstants.YavscConnectionStringName)));
|
options.UseNpgsql(builder.Configuration.GetConnectionString(
|
||||||
|
YavscConstants.YavscConnectionStringName)));
|
||||||
|
|
||||||
// other services
|
// other services
|
||||||
services
|
services
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue