diff --git a/src/Yavsc.Blogs/Constants.cs b/src/Yavsc.Blogs/Constants.cs new file mode 100644 index 00000000..4dbdfb8b --- /dev/null +++ b/src/Yavsc.Blogs/Constants.cs @@ -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"; +} diff --git a/src/Yavsc.Blogs/Controllers/BlogApiController.cs b/src/Yavsc.Blogs/Controllers/BlogApiController.cs index e442d814..6c3c73f9 100644 --- a/src/Yavsc.Blogs/Controllers/BlogApiController.cs +++ b/src/Yavsc.Blogs/Controllers/BlogApiController.cs @@ -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 { diff --git a/src/Yavsc.Blogs/Controllers/BlogTagsApiController.cs b/src/Yavsc.Blogs/Controllers/BlogTagsApiController.cs index b6053856..a5d905eb 100644 --- a/src/Yavsc.Blogs/Controllers/BlogTagsApiController.cs +++ b/src/Yavsc.Blogs/Controllers/BlogTagsApiController.cs @@ -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; diff --git a/src/Yavsc.Blogs/Controllers/CommentsApiController.cs b/src/Yavsc.Blogs/Controllers/CommentsApiController.cs index e5694c55..b9f334dc 100644 --- a/src/Yavsc.Blogs/Controllers/CommentsApiController.cs +++ b/src/Yavsc.Blogs/Controllers/CommentsApiController.cs @@ -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; diff --git a/src/Yavsc.Blogs/Controllers/FileSystemApiController.cs b/src/Yavsc.Blogs/Controllers/FileSystemApiController.cs index 29d6c879..5b067c1b 100644 --- a/src/Yavsc.Blogs/Controllers/FileSystemApiController.cs +++ b/src/Yavsc.Blogs/Controllers/FileSystemApiController.cs @@ -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; diff --git a/src/Yavsc.Blogs/Controllers/FileSystemStream.cs b/src/Yavsc.Blogs/Controllers/FileSystemStream.cs index 58dc3e2a..799d6ffb 100644 --- a/src/Yavsc.Blogs/Controllers/FileSystemStream.cs +++ b/src/Yavsc.Blogs/Controllers/FileSystemStream.cs @@ -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; diff --git a/src/Yavsc.Blogs/Controllers/PostTagsApiController.cs b/src/Yavsc.Blogs/Controllers/PostTagsApiController.cs index 646fcee6..e908edec 100644 --- a/src/Yavsc.Blogs/Controllers/PostTagsApiController.cs +++ b/src/Yavsc.Blogs/Controllers/PostTagsApiController.cs @@ -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; diff --git a/src/Yavsc.Blogs/Controllers/TagsApiController.cs b/src/Yavsc.Blogs/Controllers/TagsApiController.cs index de305733..daf0220b 100644 --- a/src/Yavsc.Blogs/Controllers/TagsApiController.cs +++ b/src/Yavsc.Blogs/Controllers/TagsApiController.cs @@ -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; diff --git a/src/Yavsc.Blogs/Program.cs b/src/Yavsc.Blogs/Program.cs index dd50b475..768d8606 100644 --- a/src/Yavsc.Blogs/Program.cs +++ b/src/Yavsc.Blogs/Program.cs @@ -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(options => - options.UseNpgsql(builder.Configuration.GetConnectionString(YavscConstants.YavscConnectionStringName))); + options.UseNpgsql(builder.Configuration.GetConnectionString( + YavscConstants.YavscConnectionStringName))); // other services services