From 98e17766b203734a1817eed94338e2d25f4395f7 Mon Sep 17 00:00:00 2001 From: transtrike Date: Sat, 13 Feb 2021 16:20:18 +0200 Subject: Project Restructure P.1 --- .../Attributes/GoodPasswordModelValidation.cs | 24 ---- .../Attributes/OnlyLettersModelValidation.cs | 20 --- .../Extensions/ConfigureAutoMapper.cs | 24 ---- .../Configurations/Extensions/ConfigureDatabase.cs | 70 ----------- .../Extensions/ConfigureDependencyInjection.cs | 38 ------ .../ConfigureExceptionHandlerMiddleware.cs | 16 --- .../Configurations/Extensions/ConfigureJWT.cs | 54 -------- .../Configurations/Extensions/ConfigureSwagger.cs | 23 ---- .../Configurations/Mapping/CommentMappings.cs | 17 --- .../Configurations/Mapping/FeedMappings.cs | 18 --- .../Configurations/Mapping/LanguageMappings.cs | 23 ---- .../Configurations/Mapping/PostMappings.cs | 17 --- .../Configurations/Mapping/RatingMappings.cs | 16 --- .../Configurations/Mapping/RoleMappings.cs | 21 ---- .../Configurations/Mapping/TechnologyMappings.cs | 23 ---- .../Configurations/Mapping/UserMappings.cs | 33 ----- src/DevHive.Web/Controllers/CommentController.cs | 83 ------------ src/DevHive.Web/Controllers/FeedController.cs | 54 -------- src/DevHive.Web/Controllers/LanguageController.cs | 87 ------------- src/DevHive.Web/Controllers/PostController.cs | 89 ------------- src/DevHive.Web/Controllers/RateController.cs | 40 ------ src/DevHive.Web/Controllers/RoleController.cs | 77 ------------ .../Controllers/TechnologyController.cs | 87 ------------- src/DevHive.Web/Controllers/UserController.cs | 140 --------------------- src/DevHive.Web/DevHive.Web.csproj | 27 ---- src/DevHive.Web/Middleware/ExceptionMiddleware.cs | 50 -------- .../Models/Comment/CreateCommentWebModel.cs | 17 --- .../Models/Comment/ReadCommentWebModel.cs | 21 ---- .../Models/Comment/UpdateCommentWebModel.cs | 13 -- src/DevHive.Web/Models/Feed/GetPageWebModel.cs | 19 --- src/DevHive.Web/Models/Feed/ReadPageWebModel.cs | 10 -- .../Models/Identity/Role/CreateRoleWebModel.cs | 14 --- .../Models/Identity/Role/RoleWebModel.cs | 14 --- .../Models/Identity/Role/UpdateRoleWebModel.cs | 15 --- .../Models/Identity/User/BaseUserWebModel.cs | 34 ----- .../Models/Identity/User/LoginWebModel.cs | 20 --- .../Models/Identity/User/ProfilePictureWebModel.cs | 7 -- .../Models/Identity/User/RegisterWebModel.cs | 14 --- .../Models/Identity/User/TokenWebModel.cs | 12 -- .../Identity/User/UpdateProfilePictureWebModel.cs | 9 -- .../Models/Identity/User/UpdateUserWebModel.cs | 34 ----- .../Models/Identity/User/UserWebModel.cs | 33 ----- .../Models/Identity/User/UsernameWebModel.cs | 15 --- .../Models/Language/CreateLanguageWebModel.cs | 14 --- .../Models/Language/LanguageWebModel.cs | 13 -- .../Models/Language/ReadLanguageWebModel.cs | 11 -- .../Models/Language/UpdateLanguageWebModel.cs | 14 --- src/DevHive.Web/Models/Post/CreatePostWebModel.cs | 16 --- .../Models/Post/Rating/RatePostWebModel.cs | 11 -- .../Models/Post/Rating/ReadPostRatingWebModel.cs | 15 --- src/DevHive.Web/Models/Post/ReadPostWebModel.cs | 26 ---- src/DevHive.Web/Models/Post/UpdatePostWebModel.cs | 21 ---- .../Models/Technology/CreateTechnologyWebModel.cs | 14 --- .../Models/Technology/ReadTechnologyWebModel.cs | 11 -- .../Models/Technology/TechnologyWebModel.cs | 13 -- .../Models/Technology/UpdateTechnologyWebModel.cs | 15 --- src/DevHive.Web/Program.cs | 23 ---- src/DevHive.Web/Properties/launchSettings.json | 36 ------ src/DevHive.Web/Startup.cs | 70 ----------- src/DevHive.Web/appsettings.json | 20 --- 60 files changed, 1815 deletions(-) delete mode 100644 src/DevHive.Web/Attributes/GoodPasswordModelValidation.cs delete mode 100644 src/DevHive.Web/Attributes/OnlyLettersModelValidation.cs delete mode 100644 src/DevHive.Web/Configurations/Extensions/ConfigureAutoMapper.cs delete mode 100644 src/DevHive.Web/Configurations/Extensions/ConfigureDatabase.cs delete mode 100644 src/DevHive.Web/Configurations/Extensions/ConfigureDependencyInjection.cs delete mode 100644 src/DevHive.Web/Configurations/Extensions/ConfigureExceptionHandlerMiddleware.cs delete mode 100644 src/DevHive.Web/Configurations/Extensions/ConfigureJWT.cs delete mode 100644 src/DevHive.Web/Configurations/Extensions/ConfigureSwagger.cs delete mode 100644 src/DevHive.Web/Configurations/Mapping/CommentMappings.cs delete mode 100644 src/DevHive.Web/Configurations/Mapping/FeedMappings.cs delete mode 100644 src/DevHive.Web/Configurations/Mapping/LanguageMappings.cs delete mode 100644 src/DevHive.Web/Configurations/Mapping/PostMappings.cs delete mode 100644 src/DevHive.Web/Configurations/Mapping/RatingMappings.cs delete mode 100644 src/DevHive.Web/Configurations/Mapping/RoleMappings.cs delete mode 100644 src/DevHive.Web/Configurations/Mapping/TechnologyMappings.cs delete mode 100644 src/DevHive.Web/Configurations/Mapping/UserMappings.cs delete mode 100644 src/DevHive.Web/Controllers/CommentController.cs delete mode 100644 src/DevHive.Web/Controllers/FeedController.cs delete mode 100644 src/DevHive.Web/Controllers/LanguageController.cs delete mode 100644 src/DevHive.Web/Controllers/PostController.cs delete mode 100644 src/DevHive.Web/Controllers/RateController.cs delete mode 100644 src/DevHive.Web/Controllers/RoleController.cs delete mode 100644 src/DevHive.Web/Controllers/TechnologyController.cs delete mode 100644 src/DevHive.Web/Controllers/UserController.cs delete mode 100644 src/DevHive.Web/DevHive.Web.csproj delete mode 100644 src/DevHive.Web/Middleware/ExceptionMiddleware.cs delete mode 100644 src/DevHive.Web/Models/Comment/CreateCommentWebModel.cs delete mode 100644 src/DevHive.Web/Models/Comment/ReadCommentWebModel.cs delete mode 100644 src/DevHive.Web/Models/Comment/UpdateCommentWebModel.cs delete mode 100644 src/DevHive.Web/Models/Feed/GetPageWebModel.cs delete mode 100644 src/DevHive.Web/Models/Feed/ReadPageWebModel.cs delete mode 100644 src/DevHive.Web/Models/Identity/Role/CreateRoleWebModel.cs delete mode 100644 src/DevHive.Web/Models/Identity/Role/RoleWebModel.cs delete mode 100644 src/DevHive.Web/Models/Identity/Role/UpdateRoleWebModel.cs delete mode 100644 src/DevHive.Web/Models/Identity/User/BaseUserWebModel.cs delete mode 100644 src/DevHive.Web/Models/Identity/User/LoginWebModel.cs delete mode 100644 src/DevHive.Web/Models/Identity/User/ProfilePictureWebModel.cs delete mode 100644 src/DevHive.Web/Models/Identity/User/RegisterWebModel.cs delete mode 100644 src/DevHive.Web/Models/Identity/User/TokenWebModel.cs delete mode 100644 src/DevHive.Web/Models/Identity/User/UpdateProfilePictureWebModel.cs delete mode 100644 src/DevHive.Web/Models/Identity/User/UpdateUserWebModel.cs delete mode 100644 src/DevHive.Web/Models/Identity/User/UserWebModel.cs delete mode 100644 src/DevHive.Web/Models/Identity/User/UsernameWebModel.cs delete mode 100644 src/DevHive.Web/Models/Language/CreateLanguageWebModel.cs delete mode 100644 src/DevHive.Web/Models/Language/LanguageWebModel.cs delete mode 100644 src/DevHive.Web/Models/Language/ReadLanguageWebModel.cs delete mode 100644 src/DevHive.Web/Models/Language/UpdateLanguageWebModel.cs delete mode 100644 src/DevHive.Web/Models/Post/CreatePostWebModel.cs delete mode 100644 src/DevHive.Web/Models/Post/Rating/RatePostWebModel.cs delete mode 100644 src/DevHive.Web/Models/Post/Rating/ReadPostRatingWebModel.cs delete mode 100644 src/DevHive.Web/Models/Post/ReadPostWebModel.cs delete mode 100644 src/DevHive.Web/Models/Post/UpdatePostWebModel.cs delete mode 100644 src/DevHive.Web/Models/Technology/CreateTechnologyWebModel.cs delete mode 100644 src/DevHive.Web/Models/Technology/ReadTechnologyWebModel.cs delete mode 100644 src/DevHive.Web/Models/Technology/TechnologyWebModel.cs delete mode 100644 src/DevHive.Web/Models/Technology/UpdateTechnologyWebModel.cs delete mode 100644 src/DevHive.Web/Program.cs delete mode 100644 src/DevHive.Web/Properties/launchSettings.json delete mode 100644 src/DevHive.Web/Startup.cs delete mode 100644 src/DevHive.Web/appsettings.json (limited to 'src/DevHive.Web') diff --git a/src/DevHive.Web/Attributes/GoodPasswordModelValidation.cs b/src/DevHive.Web/Attributes/GoodPasswordModelValidation.cs deleted file mode 100644 index 7d6a1ea..0000000 --- a/src/DevHive.Web/Attributes/GoodPasswordModelValidation.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; - -namespace DevHive.Web.Attributes -{ - public class GoodPassword : ValidationAttribute - { - public override bool IsValid(object value) - { - var stringValue = (string)value; - - for (int i = 0; i < stringValue.Length; i++) - { - if (Char.IsDigit(stringValue[i])) - { - base.ErrorMessage = "Password must be atleast 5 characters long!"; - return stringValue.Length >= 5; - } - } - base.ErrorMessage = "Password must contain atleast 1 digit!"; - return false; - } - } -} diff --git a/src/DevHive.Web/Attributes/OnlyLettersModelValidation.cs b/src/DevHive.Web/Attributes/OnlyLettersModelValidation.cs deleted file mode 100644 index 07afee9..0000000 --- a/src/DevHive.Web/Attributes/OnlyLettersModelValidation.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; - -namespace DevHive.Web.Attributes -{ - public class OnlyLetters : ValidationAttribute - { - public override bool IsValid(object value) - { - var stringValue = (string)value; - - foreach (char ch in stringValue) - { - if (!Char.IsLetter(ch)) - return false; - } - return true; - } - } -} diff --git a/src/DevHive.Web/Configurations/Extensions/ConfigureAutoMapper.cs b/src/DevHive.Web/Configurations/Extensions/ConfigureAutoMapper.cs deleted file mode 100644 index 8b7d657..0000000 --- a/src/DevHive.Web/Configurations/Extensions/ConfigureAutoMapper.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using AutoMapper; -//using AutoMapper.Configuration; -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; - -namespace DevHive.Web.Configurations.Extensions -{ - public static class ConfigureAutoMapper - { - public static void AutoMapperConfiguration(this IServiceCollection services) - { - services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); - } - - public static void UseAutoMapperConfiguration(this IApplicationBuilder app) - { - var config = new MapperConfiguration(cfg => - { - cfg.AllowNullCollections = true; - }); - } - } -} \ No newline at end of file diff --git a/src/DevHive.Web/Configurations/Extensions/ConfigureDatabase.cs b/src/DevHive.Web/Configurations/Extensions/ConfigureDatabase.cs deleted file mode 100644 index 9f02dd7..0000000 --- a/src/DevHive.Web/Configurations/Extensions/ConfigureDatabase.cs +++ /dev/null @@ -1,70 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using DevHive.Data.Models; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Builder; -using System; -using Microsoft.AspNetCore.Authentication.JwtBearer; -using DevHive.Data; - -namespace DevHive.Web.Configurations.Extensions -{ - public static class DatabaseExtensions - { - public static void DatabaseConfiguration(this IServiceCollection services, IConfiguration configuration) - { - services.AddDbContext(options => - { - options.EnableSensitiveDataLogging(true); - options.UseNpgsql(configuration.GetConnectionString("DEV")); - }); - - services.AddIdentity() - .AddRoles() - .AddEntityFrameworkStores(); - - services.Configure(options => - { - options.User.RequireUniqueEmail = true; - - options.Password.RequireDigit = true; - options.Password.RequiredLength = 5; - options.Password.RequiredUniqueChars = 0; - options.Password.RequireLowercase = false; - options.Password.RequireNonAlphanumeric = false; - options.Password.RequireUppercase = false; - - options.Lockout.AllowedForNewUsers = true; - options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(5); - options.Lockout.MaxFailedAccessAttempts = 5; - }); - - services.AddAuthorization(options => - { - options.AddPolicy("User", options => - { - options.RequireAuthenticatedUser(); - options.AuthenticationSchemes.Add(JwtBearerDefaults.AuthenticationScheme); - options.RequireRole("User"); - }); - - options.AddPolicy("Administrator", options => - { - options.RequireAuthenticatedUser(); - options.AuthenticationSchemes.Add(JwtBearerDefaults.AuthenticationScheme); - options.RequireRole("Admin"); - }); - }); - } - - public static void UseDatabaseConfiguration(this IApplicationBuilder app) - { - app.UseHttpsRedirection(); - app.UseRouting(); - - app.UseAuthentication(); - app.UseAuthorization(); - } - } -} diff --git a/src/DevHive.Web/Configurations/Extensions/ConfigureDependencyInjection.cs b/src/DevHive.Web/Configurations/Extensions/ConfigureDependencyInjection.cs deleted file mode 100644 index 88f21d4..0000000 --- a/src/DevHive.Web/Configurations/Extensions/ConfigureDependencyInjection.cs +++ /dev/null @@ -1,38 +0,0 @@ -using DevHive.Data.Interfaces.Repositories; -using DevHive.Data.Repositories; -using DevHive.Services.Interfaces; -using DevHive.Services.Services; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; - -namespace DevHive.Web.Configurations.Extensions -{ - public static class ConfigureDependencyInjection - { - public static void DependencyInjectionConfiguration(this IServiceCollection services, IConfiguration configuration) - { - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(options => - new CloudinaryService( - cloudName: configuration.GetSection("Cloud").GetSection("cloudName").Value, - apiKey: configuration.GetSection("Cloud").GetSection("apiKey").Value, - apiSecret: configuration.GetSection("Cloud").GetSection("apiSecret").Value)); - services.AddTransient(); - } - } -} diff --git a/src/DevHive.Web/Configurations/Extensions/ConfigureExceptionHandlerMiddleware.cs b/src/DevHive.Web/Configurations/Extensions/ConfigureExceptionHandlerMiddleware.cs deleted file mode 100644 index 286727f..0000000 --- a/src/DevHive.Web/Configurations/Extensions/ConfigureExceptionHandlerMiddleware.cs +++ /dev/null @@ -1,16 +0,0 @@ -using DevHive.Web.Middleware; -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; - -namespace DevHive.Web.Configurations.Extensions -{ - public static class ConfigureExceptionHandlerMiddleware - { - public static void ExceptionHandlerMiddlewareConfiguration(this IServiceCollection services) { } - - public static void UseExceptionHandlerMiddlewareConfiguration(this IApplicationBuilder app) - { - app.UseMiddleware(); - } - } -} diff --git a/src/DevHive.Web/Configurations/Extensions/ConfigureJWT.cs b/src/DevHive.Web/Configurations/Extensions/ConfigureJWT.cs deleted file mode 100644 index d422bc8..0000000 --- a/src/DevHive.Web/Configurations/Extensions/ConfigureJWT.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Text; -using System.Threading.Tasks; -using DevHive.Services.Options; -using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.IdentityModel.Tokens; - -namespace DevHive.Web.Configurations.Extensions -{ - public static class JWTExtensions - { - public static void JWTConfiguration(this IServiceCollection services, IConfiguration configuration) - { - services.AddSingleton(new JWTOptions(configuration - .GetSection("AppSettings") - .GetSection("Secret") - .Value)); - - // Get key from appsettings.json - var key = Encoding.ASCII.GetBytes(configuration - .GetSection("AppSettings") - .GetSection("Secret") - .Value); - - // Setup Jwt Authentication - services.AddAuthentication(x => - { - x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; - x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; - }) - .AddJwtBearer(x => - { - x.Events = new JwtBearerEvents - { - OnTokenValidated = context => - { - // TODO: add more authentication - return Task.CompletedTask; - } - }; - x.RequireHttpsMetadata = false; - x.SaveToken = true; - x.TokenValidationParameters = new TokenValidationParameters - { - //ValidateIssuerSigningKey = false, - IssuerSigningKey = new SymmetricSecurityKey(key), - ValidateIssuer = false, - ValidateAudience = false - }; - }); - } - } -} \ No newline at end of file diff --git a/src/DevHive.Web/Configurations/Extensions/ConfigureSwagger.cs b/src/DevHive.Web/Configurations/Extensions/ConfigureSwagger.cs deleted file mode 100644 index a0641ab..0000000 --- a/src/DevHive.Web/Configurations/Extensions/ConfigureSwagger.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.OpenApi.Models; - -namespace DevHive.Web.Configurations.Extensions -{ - public static class SwaggerExtensions - { - public static void SwaggerConfiguration(this IServiceCollection services) - { - services.AddSwaggerGen(c => - { - c.SwaggerDoc("v1", new OpenApiInfo { Title = "API", Version = "v1" }); - }); - } - - public static void UseSwaggerConfiguration(this IApplicationBuilder app) - { - app.UseSwagger(); - app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "API v1")); - } - } -} \ No newline at end of file diff --git a/src/DevHive.Web/Configurations/Mapping/CommentMappings.cs b/src/DevHive.Web/Configurations/Mapping/CommentMappings.cs deleted file mode 100644 index b8d6829..0000000 --- a/src/DevHive.Web/Configurations/Mapping/CommentMappings.cs +++ /dev/null @@ -1,17 +0,0 @@ -using AutoMapper; -using DevHive.Services.Models.Comment; -using DevHive.Web.Models.Comment; - -namespace DevHive.Web.Configurations.Mapping -{ - public class CommentMappings : Profile - { - public CommentMappings() - { - CreateMap(); - CreateMap(); - - CreateMap(); - } - } -} diff --git a/src/DevHive.Web/Configurations/Mapping/FeedMappings.cs b/src/DevHive.Web/Configurations/Mapping/FeedMappings.cs deleted file mode 100644 index 0909f6d..0000000 --- a/src/DevHive.Web/Configurations/Mapping/FeedMappings.cs +++ /dev/null @@ -1,18 +0,0 @@ -using AutoMapper; -using DevHive.Services.Models; -using DevHive.Web.Models.Comment; -using DevHive.Web.Models.Feed; - -namespace DevHive.Web.Configurations.Mapping -{ - public class FeedMappings : Profile - { - public FeedMappings() - { - CreateMap() - .ForMember(dest => dest.FirstRequestIssued, src => src.MapFrom(p => p.FirstPageTimeIssued)); - - CreateMap(); - } - } -} diff --git a/src/DevHive.Web/Configurations/Mapping/LanguageMappings.cs b/src/DevHive.Web/Configurations/Mapping/LanguageMappings.cs deleted file mode 100644 index eca0d1a..0000000 --- a/src/DevHive.Web/Configurations/Mapping/LanguageMappings.cs +++ /dev/null @@ -1,23 +0,0 @@ -using AutoMapper; -using DevHive.Web.Models.Language; -using DevHive.Services.Models.Language; - -namespace DevHive.Web.Configurations.Mapping -{ - public class LanguageMappings : Profile - { - public LanguageMappings() - { - CreateMap(); - CreateMap(); - CreateMap() - .ForMember(src => src.Id, dest => dest.Ignore()); - CreateMap(); - - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - } - } -} diff --git a/src/DevHive.Web/Configurations/Mapping/PostMappings.cs b/src/DevHive.Web/Configurations/Mapping/PostMappings.cs deleted file mode 100644 index a5b46ee..0000000 --- a/src/DevHive.Web/Configurations/Mapping/PostMappings.cs +++ /dev/null @@ -1,17 +0,0 @@ -using AutoMapper; -using DevHive.Services.Models.Post; -using DevHive.Web.Models.Post; - -namespace DevHive.Web.Configurations.Mapping -{ - public class PostMappings : Profile - { - public PostMappings() - { - CreateMap(); - CreateMap(); - - CreateMap(); - } - } -} diff --git a/src/DevHive.Web/Configurations/Mapping/RatingMappings.cs b/src/DevHive.Web/Configurations/Mapping/RatingMappings.cs deleted file mode 100644 index 4e071de..0000000 --- a/src/DevHive.Web/Configurations/Mapping/RatingMappings.cs +++ /dev/null @@ -1,16 +0,0 @@ -using AutoMapper; -using DevHive.Services.Models.Post.Rating; -using DevHive.Web.Models.Post.Rating; - -namespace DevHive.Web.Configurations.Mapping -{ - public class RatingMappings : Profile - { - public RatingMappings() - { - CreateMap(); - - CreateMap(); - } - } -} diff --git a/src/DevHive.Web/Configurations/Mapping/RoleMappings.cs b/src/DevHive.Web/Configurations/Mapping/RoleMappings.cs deleted file mode 100644 index 2ea2742..0000000 --- a/src/DevHive.Web/Configurations/Mapping/RoleMappings.cs +++ /dev/null @@ -1,21 +0,0 @@ -using AutoMapper; -using DevHive.Web.Models.Identity.Role; -using DevHive.Services.Models.Identity.Role; - -namespace DevHive.Web.Configurations.Mapping -{ - public class RoleMappings : Profile - { - public RoleMappings() - { - CreateMap(); - CreateMap() - .ForMember(src => src.Id, dest => dest.Ignore()); - CreateMap(); - - CreateMap(); - CreateMap(); - CreateMap(); - } - } -} diff --git a/src/DevHive.Web/Configurations/Mapping/TechnologyMappings.cs b/src/DevHive.Web/Configurations/Mapping/TechnologyMappings.cs deleted file mode 100644 index 708b6ac..0000000 --- a/src/DevHive.Web/Configurations/Mapping/TechnologyMappings.cs +++ /dev/null @@ -1,23 +0,0 @@ -using AutoMapper; -using DevHive.Web.Models.Technology; -using DevHive.Services.Models.Technology; - -namespace DevHive.Web.Configurations.Mapping -{ - public class TechnologyMappings : Profile - { - public TechnologyMappings() - { - CreateMap(); - CreateMap(); - CreateMap() - .ForMember(src => src.Id, dest => dest.Ignore()); - CreateMap(); - - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - } - } -} diff --git a/src/DevHive.Web/Configurations/Mapping/UserMappings.cs b/src/DevHive.Web/Configurations/Mapping/UserMappings.cs deleted file mode 100644 index f58e7ca..0000000 --- a/src/DevHive.Web/Configurations/Mapping/UserMappings.cs +++ /dev/null @@ -1,33 +0,0 @@ -using AutoMapper; -using DevHive.Services.Models.Identity.User; -using DevHive.Web.Models.Identity.User; -using DevHive.Common.Models.Identity; - -namespace DevHive.Web.Configurations.Mapping -{ - public class UserMappings : Profile - { - public UserMappings() - { - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - - CreateMap(); - - CreateMap(); - - //Update - CreateMap(); - CreateMap(); - CreateMap(); - - CreateMap(); - CreateMap(); - - CreateMap(); - CreateMap(); - } - } -} diff --git a/src/DevHive.Web/Controllers/CommentController.cs b/src/DevHive.Web/Controllers/CommentController.cs deleted file mode 100644 index c38e300..0000000 --- a/src/DevHive.Web/Controllers/CommentController.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using AutoMapper; -using System; -using DevHive.Web.Models.Comment; -using DevHive.Services.Models.Comment; -using Microsoft.AspNetCore.Authorization; -using DevHive.Services.Interfaces; - -namespace DevHive.Web.Controllers -{ - [ApiController] - [Route("/api/[controller]")] - [Authorize(Roles = "User,Admin")] - public class CommentController - { - private readonly ICommentService _commentService; - private readonly IMapper _commentMapper; - - public CommentController(ICommentService commentService, IMapper commentMapper) - { - this._commentService = commentService; - this._commentMapper = commentMapper; - } - - [HttpPost] - public async Task AddComment(Guid userId, [FromBody] CreateCommentWebModel createCommentWebModel, [FromHeader] string authorization) - { - if (!await this._commentService.ValidateJwtForCreating(userId, authorization)) - return new UnauthorizedResult(); - - CreateCommentServiceModel createCommentServiceModel = - this._commentMapper.Map(createCommentWebModel); - createCommentServiceModel.CreatorId = userId; - - Guid id = await this._commentService.AddComment(createCommentServiceModel); - - return id == Guid.Empty ? - new BadRequestObjectResult("Could not create comment!") : - new OkObjectResult(new { Id = id }); - } - - [HttpGet] - [AllowAnonymous] - public async Task GetCommentById(Guid id) - { - ReadCommentServiceModel readCommentServiceModel = await this._commentService.GetCommentById(id); - ReadCommentWebModel readCommentWebModel = this._commentMapper.Map(readCommentServiceModel); - - return new OkObjectResult(readCommentWebModel); - } - - [HttpPut] - public async Task UpdateComment(Guid userId, [FromBody] UpdateCommentWebModel updateCommentWebModel, [FromHeader] string authorization) - { - if (!await this._commentService.ValidateJwtForComment(updateCommentWebModel.CommentId, authorization)) - return new UnauthorizedResult(); - - UpdateCommentServiceModel updateCommentServiceModel = - this._commentMapper.Map(updateCommentWebModel); - updateCommentServiceModel.CreatorId = userId; - - Guid id = await this._commentService.UpdateComment(updateCommentServiceModel); - - return id == Guid.Empty ? - new BadRequestObjectResult("Unable to update comment!") : - new OkObjectResult(new { Id = id }); - } - - [HttpDelete] - public async Task DeleteComment(Guid id, [FromHeader] string authorization) - { - if (!await this._commentService.ValidateJwtForComment(id, authorization)) - return new UnauthorizedResult(); - - return await this._commentService.DeleteComment(id) ? - new OkResult() : - new BadRequestObjectResult("Could not delete Comment"); - } - - } -} - diff --git a/src/DevHive.Web/Controllers/FeedController.cs b/src/DevHive.Web/Controllers/FeedController.cs deleted file mode 100644 index abca3e4..0000000 --- a/src/DevHive.Web/Controllers/FeedController.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Threading.Tasks; -using AutoMapper; -using DevHive.Services.Interfaces; -using DevHive.Services.Models; -using DevHive.Web.Models.Comment; -using DevHive.Web.Models.Feed; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; - -namespace DevHive.Web.Controllers -{ - [ApiController] - [Route("/api/[controller]")] - [Authorize(Roles = "User,Admin")] - public class FeedController - { - private readonly IFeedService _feedService; - private readonly IMapper _mapper; - - public FeedController(IFeedService feedService, IMapper mapper) - { - this._feedService = feedService; - this._mapper = mapper; - } - - [HttpPost] - [Route("GetPosts")] - public async Task GetPosts(Guid userId, [FromBody] GetPageWebModel getPageWebModel) - { - GetPageServiceModel getPageServiceModel = this._mapper.Map(getPageWebModel); - getPageServiceModel.UserId = userId; - - ReadPageServiceModel readPageServiceModel = await this._feedService.GetPage(getPageServiceModel); - ReadPageWebModel readPageWebModel = this._mapper.Map(readPageServiceModel); - - return new OkObjectResult(readPageWebModel); - } - - [HttpPost] - [Route("GetUserPosts")] - [AllowAnonymous] - public async Task GetUserPosts(string username, [FromBody] GetPageWebModel getPageWebModel) - { - GetPageServiceModel getPageServiceModel = this._mapper.Map(getPageWebModel); - getPageServiceModel.Username = username; - - ReadPageServiceModel readPageServiceModel = await this._feedService.GetUserPage(getPageServiceModel); - ReadPageWebModel readPageWebModel = this._mapper.Map(readPageServiceModel); - - return new OkObjectResult(readPageWebModel); - } - } -} diff --git a/src/DevHive.Web/Controllers/LanguageController.cs b/src/DevHive.Web/Controllers/LanguageController.cs deleted file mode 100644 index 5b0d5de..0000000 --- a/src/DevHive.Web/Controllers/LanguageController.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using AutoMapper; -using DevHive.Services.Interfaces; -using DevHive.Services.Models.Language; -using DevHive.Web.Models.Language; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; - -namespace DevHive.Web.Controllers -{ - [ApiController] - [Route("/api/[controller]")] - public class LanguageController - { - private readonly ILanguageService _languageService; - private readonly IMapper _languageMapper; - - public LanguageController(ILanguageService languageService, IMapper mapper) - { - this._languageService = languageService; - this._languageMapper = mapper; - } - - [HttpPost] - [Authorize(Roles = "Admin")] - public async Task Create([FromBody] CreateLanguageWebModel createLanguageWebModel) - { - CreateLanguageServiceModel languageServiceModel = this._languageMapper.Map(createLanguageWebModel); - - Guid id = await this._languageService.CreateLanguage(languageServiceModel); - - return id == Guid.Empty ? - new BadRequestObjectResult($"Could not create language {createLanguageWebModel.Name}") : - new OkObjectResult(new { Id = id }); - } - - [HttpGet] - [AllowAnonymous] - public async Task GetById(Guid id) - { - ReadLanguageServiceModel languageServiceModel = await this._languageService.GetLanguageById(id); - ReadLanguageWebModel languageWebModel = this._languageMapper.Map(languageServiceModel); - - return new OkObjectResult(languageWebModel); - } - - [HttpGet] - [Route("GetLanguages")] - [Authorize(Roles = "User,Admin")] - public IActionResult GetAllExistingLanguages() - { - HashSet languageServiceModels = this._languageService.GetLanguages(); - HashSet languageWebModels = this._languageMapper.Map>(languageServiceModels); - - return new OkObjectResult(languageWebModels); - } - - [HttpPut] - [Authorize(Roles = "Admin")] - public async Task Update(Guid id, [FromBody] UpdateLanguageWebModel updateModel) - { - UpdateLanguageServiceModel updatelanguageServiceModel = this._languageMapper.Map(updateModel); - updatelanguageServiceModel.Id = id; - - bool result = await this._languageService.UpdateLanguage(updatelanguageServiceModel); - - if (!result) - return new BadRequestObjectResult("Could not update Language"); - - return new OkResult(); - } - - [HttpDelete] - [Authorize(Roles = "Admin")] - public async Task Delete(Guid id) - { - bool result = await this._languageService.DeleteLanguage(id); - - if (!result) - return new BadRequestObjectResult("Could not delete Language"); - - return new OkResult(); - } - } -} diff --git a/src/DevHive.Web/Controllers/PostController.cs b/src/DevHive.Web/Controllers/PostController.cs deleted file mode 100644 index d3fdbf6..0000000 --- a/src/DevHive.Web/Controllers/PostController.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using AutoMapper; -using System; -using DevHive.Web.Models.Post; -using DevHive.Services.Models.Post; -using Microsoft.AspNetCore.Authorization; -using DevHive.Services.Interfaces; - -namespace DevHive.Web.Controllers -{ - [ApiController] - [Route("/api/[controller]")] - [Authorize(Roles = "User,Admin")] - public class PostController - { - private readonly IPostService _postService; - private readonly IMapper _postMapper; - - public PostController(IPostService postService, IMapper postMapper) - { - this._postService = postService; - this._postMapper = postMapper; - } - - #region Create - [HttpPost] - public async Task Create(Guid userId, [FromForm] CreatePostWebModel createPostWebModel, [FromHeader] string authorization) - { - if (!await this._postService.ValidateJwtForCreating(userId, authorization)) - return new UnauthorizedResult(); - - CreatePostServiceModel createPostServiceModel = - this._postMapper.Map(createPostWebModel); - createPostServiceModel.CreatorId = userId; - - Guid id = await this._postService.CreatePost(createPostServiceModel); - - return id == Guid.Empty ? - new BadRequestObjectResult("Could not create post!") : - new OkObjectResult(new { Id = id }); - } - #endregion - - #region Read - [HttpGet] - [AllowAnonymous] - public async Task GetById(Guid id) - { - ReadPostServiceModel postServiceModel = await this._postService.GetPostById(id); - ReadPostWebModel postWebModel = this._postMapper.Map(postServiceModel); - - return new OkObjectResult(postWebModel); - } - #endregion - - #region Update - [HttpPut] - public async Task Update(Guid userId, [FromForm] UpdatePostWebModel updatePostWebModel, [FromHeader] string authorization) - { - if (!await this._postService.ValidateJwtForPost(updatePostWebModel.PostId, authorization)) - return new UnauthorizedResult(); - - UpdatePostServiceModel updatePostServiceModel = - this._postMapper.Map(updatePostWebModel); - updatePostServiceModel.CreatorId = userId; - - Guid id = await this._postService.UpdatePost(updatePostServiceModel); - - return id == Guid.Empty ? - new BadRequestObjectResult("Could not update post!") : - new OkObjectResult(new { Id = id }); - } - #endregion - - #region Delete - [HttpDelete] - public async Task Delete(Guid id, [FromHeader] string authorization) - { - if (!await this._postService.ValidateJwtForPost(id, authorization)) - return new UnauthorizedResult(); - - return await this._postService.DeletePost(id) ? - new OkResult() : - new BadRequestObjectResult("Could not delete Post"); - } - #endregion - } -} diff --git a/src/DevHive.Web/Controllers/RateController.cs b/src/DevHive.Web/Controllers/RateController.cs deleted file mode 100644 index 68b859b..0000000 --- a/src/DevHive.Web/Controllers/RateController.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Threading.Tasks; -using AutoMapper; -using DevHive.Services.Interfaces; -using DevHive.Services.Models.Post.Rating; -using DevHive.Web.Models.Post.Rating; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; - -namespace DevHive.Web.Controllers -{ - [ApiController] - [Route("api/[controller]")] - public class RateController - { - private readonly IRateService _rateService; - private readonly IUserService _userService; - private readonly IMapper _mapper; - - public RateController(IRateService rateService, IUserService userService, IMapper mapper) - { - this._rateService = rateService; - this._userService = userService; - this._mapper = mapper; - } - - [HttpPost] - [Authorize(Roles = "Admin,User")] - public async Task RatePost(Guid userId, [FromBody] RatePostWebModel ratePostWebModel, [FromHeader] string authorization) - { - RatePostServiceModel ratePostServiceModel = this._mapper.Map(ratePostWebModel); - ratePostServiceModel.UserId = userId; - - ReadPostRatingServiceModel readPostRatingServiceModel = await this._rateService.RatePost(ratePostServiceModel); - ReadPostRatingWebModel readPostRatingWebModel = this._mapper.Map(readPostRatingServiceModel); - - return new OkObjectResult(readPostRatingWebModel); - } - } -} diff --git a/src/DevHive.Web/Controllers/RoleController.cs b/src/DevHive.Web/Controllers/RoleController.cs deleted file mode 100644 index 0d2a2eb..0000000 --- a/src/DevHive.Web/Controllers/RoleController.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using DevHive.Web.Models.Identity.Role; -using AutoMapper; -using System; -using DevHive.Services.Interfaces; -using DevHive.Services.Models.Identity.Role; -using Microsoft.AspNetCore.Authorization; - -namespace DevHive.Web.Controllers -{ - [ApiController] - [Route("/api/[controller]")] - public class RoleController - { - private readonly IRoleService _roleService; - private readonly IMapper _roleMapper; - - public RoleController(IRoleService roleService, IMapper mapper) - { - this._roleService = roleService; - this._roleMapper = mapper; - } - - [HttpPost] - [Authorize(Roles = "Admin")] - public async Task Create([FromBody] CreateRoleWebModel createRoleWebModel) - { - CreateRoleServiceModel roleServiceModel = - this._roleMapper.Map(createRoleWebModel); - - Guid id = await this._roleService.CreateRole(roleServiceModel); - - return id == Guid.Empty ? - new BadRequestObjectResult($"Could not create role {createRoleWebModel.Name}") : - new OkObjectResult(new { Id = id }); - } - - [HttpGet] - [Authorize(Roles = "User,Admin")] - public async Task GetById(Guid id) - { - RoleServiceModel roleServiceModel = await this._roleService.GetRoleById(id); - RoleWebModel roleWebModel = this._roleMapper.Map(roleServiceModel); - - return new OkObjectResult(roleWebModel); - } - - [HttpPut] - [Authorize(Roles = "Admin")] - public async Task Update(Guid id, [FromBody] UpdateRoleWebModel updateRoleWebModel) - { - UpdateRoleServiceModel updateRoleServiceModel = - this._roleMapper.Map(updateRoleWebModel); - updateRoleServiceModel.Id = id; - - bool result = await this._roleService.UpdateRole(updateRoleServiceModel); - - if (!result) - return new BadRequestObjectResult("Could not update role!"); - - return new OkResult(); - } - - [HttpDelete] - [Authorize(Roles = "Admin")] - public async Task Delete(Guid id) - { - bool result = await this._roleService.DeleteRole(id); - - if (!result) - return new BadRequestObjectResult("Could not delete role!"); - - return new OkResult(); - } - } -} diff --git a/src/DevHive.Web/Controllers/TechnologyController.cs b/src/DevHive.Web/Controllers/TechnologyController.cs deleted file mode 100644 index e507899..0000000 --- a/src/DevHive.Web/Controllers/TechnologyController.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using AutoMapper; -using DevHive.Services.Interfaces; -using DevHive.Services.Models.Technology; -using DevHive.Web.Models.Technology; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; - -namespace DevHive.Web.Controllers -{ - [ApiController] - [Route("/api/[controller]")] - public class TechnologyController - { - private readonly ITechnologyService _technologyService; - private readonly IMapper _technologyMapper; - - public TechnologyController(ITechnologyService technologyService, IMapper technologyMapper) - { - this._technologyService = technologyService; - this._technologyMapper = technologyMapper; - } - - [HttpPost] - [Authorize(Roles = "Admin")] - public async Task Create([FromBody] CreateTechnologyWebModel createTechnologyWebModel) - { - CreateTechnologyServiceModel technologyServiceModel = this._technologyMapper.Map(createTechnologyWebModel); - - Guid id = await this._technologyService.CreateTechnology(technologyServiceModel); - - return id == Guid.Empty ? - new BadRequestObjectResult($"Could not create technology {createTechnologyWebModel.Name}") : - new OkObjectResult(new { Id = id }); - } - - [HttpGet] - [AllowAnonymous] - public async Task GetById(Guid id) - { - ReadTechnologyServiceModel readTechnologyServiceModel = await this._technologyService.GetTechnologyById(id); - ReadTechnologyWebModel readTechnologyWebModel = this._technologyMapper.Map(readTechnologyServiceModel); - - return new OkObjectResult(readTechnologyWebModel); - } - - [HttpGet] - [Route("GetTechnologies")] - [Authorize(Roles = "User,Admin")] - public IActionResult GetAllExistingTechnologies() - { - HashSet technologyServiceModels = this._technologyService.GetTechnologies(); - HashSet languageWebModels = this._technologyMapper.Map>(technologyServiceModels); - - return new OkObjectResult(languageWebModels); - } - - [HttpPut] - [Authorize(Roles = "Admin")] - public async Task Update(Guid id, [FromBody] UpdateTechnologyWebModel updateModel) - { - UpdateTechnologyServiceModel updateTechnologyServiceModel = this._technologyMapper.Map(updateModel); - updateTechnologyServiceModel.Id = id; - - bool result = await this._technologyService.UpdateTechnology(updateTechnologyServiceModel); - - if (!result) - return new BadRequestObjectResult("Could not update Technology"); - - return new OkResult(); - } - - [HttpDelete] - [Authorize(Roles = "Admin")] - public async Task Delete(Guid id) - { - bool result = await this._technologyService.DeleteTechnology(id); - - if (!result) - return new BadRequestObjectResult("Could not delete Technology"); - - return new OkResult(); - } - } -} diff --git a/src/DevHive.Web/Controllers/UserController.cs b/src/DevHive.Web/Controllers/UserController.cs deleted file mode 100644 index 109bbaa..0000000 --- a/src/DevHive.Web/Controllers/UserController.cs +++ /dev/null @@ -1,140 +0,0 @@ -using System; -using System.Threading.Tasks; -using AutoMapper; -using DevHive.Services.Models.Identity.User; -using DevHive.Web.Models.Identity.User; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using DevHive.Common.Models.Identity; -using DevHive.Services.Interfaces; -using Microsoft.Extensions.Hosting; - -namespace DevHive.Web.Controllers -{ - [ApiController] - [Route("/api/[controller]")] - public class UserController : ControllerBase - { - private readonly IUserService _userService; - private readonly IMapper _userMapper; - - public UserController(IUserService userService, IMapper mapper) - { - this._userService = userService; - this._userMapper = mapper; - } - - #region Authentication - [HttpPost] - [Route("Login")] - [AllowAnonymous] - public async Task Login([FromBody] LoginWebModel loginModel) - { - LoginServiceModel loginServiceModel = this._userMapper.Map(loginModel); - - TokenModel TokenModel = await this._userService.LoginUser(loginServiceModel); - TokenWebModel tokenWebModel = this._userMapper.Map(TokenModel); - - return new OkObjectResult(tokenWebModel); - } - - [HttpPost] - [Route("Register")] - [AllowAnonymous] - public async Task Register([FromBody] RegisterWebModel registerModel) - { - RegisterServiceModel registerServiceModel = this._userMapper.Map(registerModel); - - TokenModel TokenModel = await this._userService.RegisterUser(registerServiceModel); - TokenWebModel tokenWebModel = this._userMapper.Map(TokenModel); - - return new CreatedResult("Register", tokenWebModel); - } - #endregion - - #region Read - [HttpGet] - [Authorize(Roles = "User,Admin")] - public async Task GetById(Guid id, [FromHeader] string authorization) - { - if (!await this._userService.ValidJWT(id, authorization)) - return new UnauthorizedResult(); - - UserServiceModel userServiceModel = await this._userService.GetUserById(id); - UserWebModel userWebModel = this._userMapper.Map(userServiceModel); - - return new OkObjectResult(userWebModel); - } - - [HttpGet] - [Route("GetUser")] - [AllowAnonymous] - public async Task GetUser(string username) - { - UserServiceModel friendServiceModel = await this._userService.GetUserByUsername(username); - UserWebModel friend = this._userMapper.Map(friendServiceModel); - - return new OkObjectResult(friend); - } - #endregion - - #region Update - [HttpPut] - [Authorize(Roles = "User,Admin")] - public async Task Update(Guid id, [FromBody] UpdateUserWebModel updateUserWebModel, [FromHeader] string authorization) - { - if (!await this._userService.ValidJWT(id, authorization)) - return new UnauthorizedResult(); - - UpdateUserServiceModel updateUserServiceModel = this._userMapper.Map(updateUserWebModel); - updateUserServiceModel.Id = id; - - UserServiceModel userServiceModel = await this._userService.UpdateUser(updateUserServiceModel); - UserWebModel userWebModel = this._userMapper.Map(userServiceModel); - - return new AcceptedResult("UpdateUser", userWebModel); - } - - [HttpPut] - [Route("ProfilePicture")] - [Authorize(Roles = "User,Admin")] - public async Task UpdateProfilePicture(Guid userId, [FromForm] UpdateProfilePictureWebModel updateProfilePictureWebModel, [FromHeader] string authorization) - { - if (!await this._userService.ValidJWT(userId, authorization)) - return new UnauthorizedResult(); - - UpdateProfilePictureServiceModel updateProfilePictureServiceModel = this._userMapper.Map(updateProfilePictureWebModel); - updateProfilePictureServiceModel.UserId = userId; - - ProfilePictureServiceModel profilePictureServiceModel = await this._userService.UpdateProfilePicture(updateProfilePictureServiceModel); - ProfilePictureWebModel profilePictureWebModel = this._userMapper.Map(profilePictureServiceModel); - - return new AcceptedResult("UpdateProfilePicture", profilePictureWebModel); - } - #endregion - - #region Delete - [HttpDelete] - [Authorize(Roles = "User,Admin")] - public async Task Delete(Guid id, [FromHeader] string authorization) - { - if (!await this._userService.ValidJWT(id, authorization)) - return new UnauthorizedResult(); - - bool result = await this._userService.DeleteUser(id); - if (!result) - return new BadRequestObjectResult("Could not delete User"); - - return new OkResult(); - } - #endregion - - [HttpPost] - [Authorize(Roles = "User,Admin")] - [Route("SuperSecretPromotionToAdmin")] - public async Task SuperSecretPromotionToAdmin(Guid userId) - { - return new OkObjectResult(await this._userService.SuperSecretPromotionToAdmin(userId)); - } - } -} diff --git a/src/DevHive.Web/DevHive.Web.csproj b/src/DevHive.Web/DevHive.Web.csproj deleted file mode 100644 index 0aa2831..0000000 --- a/src/DevHive.Web/DevHive.Web.csproj +++ /dev/null @@ -1,27 +0,0 @@ - - - net5.0 - - - true - latest - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - - - - - - diff --git a/src/DevHive.Web/Middleware/ExceptionMiddleware.cs b/src/DevHive.Web/Middleware/ExceptionMiddleware.cs deleted file mode 100644 index cb6d4ca..0000000 --- a/src/DevHive.Web/Middleware/ExceptionMiddleware.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Net; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; - -namespace DevHive.Web.Middleware -{ - public class ExceptionMiddleware - { - private readonly RequestDelegate _next; - // private readonly ILogger _logger; - - public ExceptionMiddleware(RequestDelegate next) - { - this._next = next; - // this._logger = logger; - } - // public ExceptionMiddleware(RequestDelegate next, ILogger logger) - // { - // this._logger = logger; - // this._next = next; - // } - - public async Task InvokeAsync(HttpContext httpContext) - { - try - { - await this._next(httpContext); - } - catch (Exception ex) - { - // this._logger.LogError($"Something went wrong: {ex}"); - await HandleExceptionAsync(httpContext, ex); - } - } - - private Task HandleExceptionAsync(HttpContext context, Exception exception) - { - context.Response.ContentType = "application/json"; - context.Response.StatusCode = (int)HttpStatusCode.BadRequest; - - return context.Response.WriteAsync(new - { - StatusCode = context.Response.StatusCode, - Message = exception.Message - }.ToString()); - } - } -} diff --git a/src/DevHive.Web/Models/Comment/CreateCommentWebModel.cs b/src/DevHive.Web/Models/Comment/CreateCommentWebModel.cs deleted file mode 100644 index 8b2bf8d..0000000 --- a/src/DevHive.Web/Models/Comment/CreateCommentWebModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; - -namespace DevHive.Web.Models.Comment -{ - public class CreateCommentWebModel - { - [NotNull] - [Required] - public Guid PostId { get; set; } - - [NotNull] - [Required] - public string Message { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Comment/ReadCommentWebModel.cs b/src/DevHive.Web/Models/Comment/ReadCommentWebModel.cs deleted file mode 100644 index 4d3aff7..0000000 --- a/src/DevHive.Web/Models/Comment/ReadCommentWebModel.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -namespace DevHive.Web.Models.Comment -{ - public class ReadCommentWebModel - { - public Guid CommentId { get; set; } - - public Guid PostId { get; set; } - - public string IssuerFirstName { get; set; } - - public string IssuerLastName { get; set; } - - public string IssuerUsername { get; set; } - - public string Message { get; set; } - - public DateTime TimeCreated { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Comment/UpdateCommentWebModel.cs b/src/DevHive.Web/Models/Comment/UpdateCommentWebModel.cs deleted file mode 100644 index b5d7970..0000000 --- a/src/DevHive.Web/Models/Comment/UpdateCommentWebModel.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; - -namespace DevHive.Web.Models.Comment -{ - public class UpdateCommentWebModel - { - public Guid CommentId { get; set; } - - public Guid PostId { get; set; } - - public string NewMessage { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Feed/GetPageWebModel.cs b/src/DevHive.Web/Models/Feed/GetPageWebModel.cs deleted file mode 100644 index 4ea44cc..0000000 --- a/src/DevHive.Web/Models/Feed/GetPageWebModel.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.ComponentModel; -using System.ComponentModel.DataAnnotations; - -namespace DevHive.Web.Models.Feed -{ - public class GetPageWebModel - { - [Range(1, int.MaxValue)] - public int PageNumber { get; set; } - - [Required] - public DateTime FirstPageTimeIssued { get; set; } - - [DefaultValue(5)] - [Range(1, int.MaxValue)] - public int PageSize { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Feed/ReadPageWebModel.cs b/src/DevHive.Web/Models/Feed/ReadPageWebModel.cs deleted file mode 100644 index f429313..0000000 --- a/src/DevHive.Web/Models/Feed/ReadPageWebModel.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Collections.Generic; -using DevHive.Web.Models.Post; - -namespace DevHive.Web.Models.Comment -{ - public class ReadPageWebModel - { - public List Posts { get; set; } = new(); - } -} diff --git a/src/DevHive.Web/Models/Identity/Role/CreateRoleWebModel.cs b/src/DevHive.Web/Models/Identity/Role/CreateRoleWebModel.cs deleted file mode 100644 index 859cdd9..0000000 --- a/src/DevHive.Web/Models/Identity/Role/CreateRoleWebModel.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; - -namespace DevHive.Web.Models.Identity.Role -{ - public class CreateRoleWebModel - { - [NotNull] - [Required] - [MinLength(3)] - [MaxLength(50)] - public string Name { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Identity/Role/RoleWebModel.cs b/src/DevHive.Web/Models/Identity/Role/RoleWebModel.cs deleted file mode 100644 index 99b0f50..0000000 --- a/src/DevHive.Web/Models/Identity/Role/RoleWebModel.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; - -namespace DevHive.Web.Models.Identity.Role -{ - public class RoleWebModel - { - [NotNull] - [Required] - [MinLength(3)] - [MaxLength(50)] - public string Name { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Identity/Role/UpdateRoleWebModel.cs b/src/DevHive.Web/Models/Identity/Role/UpdateRoleWebModel.cs deleted file mode 100644 index 3870481..0000000 --- a/src/DevHive.Web/Models/Identity/Role/UpdateRoleWebModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; - -namespace DevHive.Web.Models.Identity.Role -{ - public class UpdateRoleWebModel - { - [NotNull] - [Required] - [MinLength(3)] - [MaxLength(50)] - public string Name { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Identity/User/BaseUserWebModel.cs b/src/DevHive.Web/Models/Identity/User/BaseUserWebModel.cs deleted file mode 100644 index 297e1a5..0000000 --- a/src/DevHive.Web/Models/Identity/User/BaseUserWebModel.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; -using DevHive.Web.Attributes; - -namespace DevHive.Web.Models.Identity.User -{ - public class BaseUserWebModel - { - [NotNull] - [Required] - [MinLength(3)] - [MaxLength(50)] - public string UserName { get; set; } - - [NotNull] - [Required] - [EmailAddress] - public string Email { get; set; } - - [NotNull] - [Required] - [MinLength(3)] - [MaxLength(30)] - [OnlyLetters(ErrorMessage = "First name can only contain letters!")] - public string FirstName { get; set; } - - [NotNull] - [Required] - [MinLength(3)] - [MaxLength(30)] - [OnlyLetters(ErrorMessage = "Last name can only contain letters!")] - public string LastName { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Identity/User/LoginWebModel.cs b/src/DevHive.Web/Models/Identity/User/LoginWebModel.cs deleted file mode 100644 index ccd806f..0000000 --- a/src/DevHive.Web/Models/Identity/User/LoginWebModel.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; -using DevHive.Web.Attributes; - -namespace DevHive.Web.Models.Identity.User -{ - public class LoginWebModel - { - [NotNull] - [Required] - [MinLength(3)] - [MaxLength(50)] - public string UserName { get; set; } - - [NotNull] - [Required] - [GoodPassword] - public string Password { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Identity/User/ProfilePictureWebModel.cs b/src/DevHive.Web/Models/Identity/User/ProfilePictureWebModel.cs deleted file mode 100644 index 9fb1516..0000000 --- a/src/DevHive.Web/Models/Identity/User/ProfilePictureWebModel.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace DevHive.Web.Models.Identity.User -{ - public class ProfilePictureWebModel - { - public string ProfilePictureURL { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Identity/User/RegisterWebModel.cs b/src/DevHive.Web/Models/Identity/User/RegisterWebModel.cs deleted file mode 100644 index 0fc7ec6..0000000 --- a/src/DevHive.Web/Models/Identity/User/RegisterWebModel.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; -using DevHive.Web.Attributes; - -namespace DevHive.Web.Models.Identity.User -{ - public class RegisterWebModel : BaseUserWebModel - { - [NotNull] - [Required] - [GoodPassword] - public string Password { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Identity/User/TokenWebModel.cs b/src/DevHive.Web/Models/Identity/User/TokenWebModel.cs deleted file mode 100644 index 154b64b..0000000 --- a/src/DevHive.Web/Models/Identity/User/TokenWebModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace DevHive.Web.Models.Identity.User -{ - public class TokenWebModel - { - public TokenWebModel(string token) - { - this.Token = token; - } - - public string Token { get; set; } - } -} \ No newline at end of file diff --git a/src/DevHive.Web/Models/Identity/User/UpdateProfilePictureWebModel.cs b/src/DevHive.Web/Models/Identity/User/UpdateProfilePictureWebModel.cs deleted file mode 100644 index 6efe968..0000000 --- a/src/DevHive.Web/Models/Identity/User/UpdateProfilePictureWebModel.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Microsoft.AspNetCore.Http; - -namespace DevHive.Web.Models.Identity.User -{ - public class UpdateProfilePictureWebModel - { - public IFormFile Picture { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Identity/User/UpdateUserWebModel.cs b/src/DevHive.Web/Models/Identity/User/UpdateUserWebModel.cs deleted file mode 100644 index 62901f6..0000000 --- a/src/DevHive.Web/Models/Identity/User/UpdateUserWebModel.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; -using DevHive.Web.Attributes; -using DevHive.Web.Models.Identity.Role; -using DevHive.Web.Models.Language; -using DevHive.Web.Models.Technology; - -namespace DevHive.Web.Models.Identity.User -{ - public class UpdateUserWebModel : BaseUserWebModel - { - [NotNull] - [Required] - [GoodPassword] - public string Password { get; set; } - - [NotNull] - [Required] - public HashSet Friends { get; set; } - - [NotNull] - [Required] - public HashSet Roles { get; set; } - - [NotNull] - [Required] - public HashSet Languages { get; set; } - - [NotNull] - [Required] - public HashSet Technologies { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Identity/User/UserWebModel.cs b/src/DevHive.Web/Models/Identity/User/UserWebModel.cs deleted file mode 100644 index 7ab8cca..0000000 --- a/src/DevHive.Web/Models/Identity/User/UserWebModel.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; -using DevHive.Common.Models.Misc; -using DevHive.Web.Models.Identity.Role; -using DevHive.Web.Models.Language; -using DevHive.Web.Models.Technology; - -namespace DevHive.Web.Models.Identity.User -{ - public class UserWebModel : BaseUserWebModel - { - public string ProfilePictureURL { get; set; } - - [NotNull] - [Required] - public HashSet Roles { get; set; } = new(); - - [NotNull] - [Required] - public HashSet Friends { get; set; } = new(); - - [NotNull] - [Required] - public HashSet Languages { get; set; } = new(); - - [NotNull] - [Required] - public HashSet Technologies { get; set; } = new(); - - public List Posts { get; set; } = new(); - } -} diff --git a/src/DevHive.Web/Models/Identity/User/UsernameWebModel.cs b/src/DevHive.Web/Models/Identity/User/UsernameWebModel.cs deleted file mode 100644 index c533bba..0000000 --- a/src/DevHive.Web/Models/Identity/User/UsernameWebModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; -using DevHive.Web.Attributes; - -namespace DevHive.Web.Models.Identity.User -{ - public class UsernameWebModel - { - [NotNull] - [Required] - [MinLength(3)] - [MaxLength(50)] - public string UserName { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Language/CreateLanguageWebModel.cs b/src/DevHive.Web/Models/Language/CreateLanguageWebModel.cs deleted file mode 100644 index a739e7f..0000000 --- a/src/DevHive.Web/Models/Language/CreateLanguageWebModel.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; - -namespace DevHive.Web.Models.Language -{ - public class CreateLanguageWebModel - { - [NotNull] - [Required] - [MinLength(3)] - [MaxLength(50)] - public string Name { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Language/LanguageWebModel.cs b/src/DevHive.Web/Models/Language/LanguageWebModel.cs deleted file mode 100644 index 7515e70..0000000 --- a/src/DevHive.Web/Models/Language/LanguageWebModel.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; - -namespace DevHive.Web.Models.Language -{ - public class LanguageWebModel - { - [NotNull] - [Required] - public Guid Id { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Language/ReadLanguageWebModel.cs b/src/DevHive.Web/Models/Language/ReadLanguageWebModel.cs deleted file mode 100644 index 3d9d5b6..0000000 --- a/src/DevHive.Web/Models/Language/ReadLanguageWebModel.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace DevHive.Web.Models.Language -{ - public class ReadLanguageWebModel - { - public Guid Id { get; set; } - - public string Name { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Language/UpdateLanguageWebModel.cs b/src/DevHive.Web/Models/Language/UpdateLanguageWebModel.cs deleted file mode 100644 index 128d534..0000000 --- a/src/DevHive.Web/Models/Language/UpdateLanguageWebModel.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; - -namespace DevHive.Web.Models.Language -{ - public class UpdateLanguageWebModel - { - [NotNull] - [Required] - [MinLength(3)] - [MaxLength(50)] - public string Name { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Post/CreatePostWebModel.cs b/src/DevHive.Web/Models/Post/CreatePostWebModel.cs deleted file mode 100644 index 237259d..0000000 --- a/src/DevHive.Web/Models/Post/CreatePostWebModel.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; -using Microsoft.AspNetCore.Http; - -namespace DevHive.Web.Models.Post -{ - public class CreatePostWebModel - { - [NotNull] - [Required] - public string Message { get; set; } - - public List Files { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Post/Rating/RatePostWebModel.cs b/src/DevHive.Web/Models/Post/Rating/RatePostWebModel.cs deleted file mode 100644 index 5f0e58f..0000000 --- a/src/DevHive.Web/Models/Post/Rating/RatePostWebModel.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace DevHive.Web.Models.Post.Rating -{ - public class RatePostWebModel - { - public Guid PostId { get; set; } - - public bool Liked { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Post/Rating/ReadPostRatingWebModel.cs b/src/DevHive.Web/Models/Post/Rating/ReadPostRatingWebModel.cs deleted file mode 100644 index a551fb8..0000000 --- a/src/DevHive.Web/Models/Post/Rating/ReadPostRatingWebModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace DevHive.Web.Models.Post.Rating -{ - public class ReadPostRatingWebModel - { - public Guid Id { get; set; } - - public Guid PostId { get; set; } - - public int Likes { get; set; } - - public int Dislikes { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Post/ReadPostWebModel.cs b/src/DevHive.Web/Models/Post/ReadPostWebModel.cs deleted file mode 100644 index 8238f47..0000000 --- a/src/DevHive.Web/Models/Post/ReadPostWebModel.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using DevHive.Common.Models.Misc; - -namespace DevHive.Web.Models.Post -{ - public class ReadPostWebModel - { - public Guid PostId { get; set; } - - public string CreatorFirstName { get; set; } - - public string CreatorLastName { get; set; } - - public string CreatorUsername { get; set; } - - public string Message { get; set; } - - public DateTime TimeCreated { get; set; } - - public List Comments { get; set; } - - public List FileUrls { get; set; } - // public List Files { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Post/UpdatePostWebModel.cs b/src/DevHive.Web/Models/Post/UpdatePostWebModel.cs deleted file mode 100644 index a0c9b61..0000000 --- a/src/DevHive.Web/Models/Post/UpdatePostWebModel.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; -using Microsoft.AspNetCore.Http; - -namespace DevHive.Web.Models.Post -{ - public class UpdatePostWebModel - { - [Required] - [NotNull] - public Guid PostId { get; set; } - - [NotNull] - [Required] - public string NewMessage { get; set; } - - public List Files { get; set; } = new(); - } -} diff --git a/src/DevHive.Web/Models/Technology/CreateTechnologyWebModel.cs b/src/DevHive.Web/Models/Technology/CreateTechnologyWebModel.cs deleted file mode 100644 index ec9ec15..0000000 --- a/src/DevHive.Web/Models/Technology/CreateTechnologyWebModel.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; - -namespace DevHive.Web.Models.Technology -{ - public class CreateTechnologyWebModel - { - [NotNull] - [Required] - [MinLength(3)] - [MaxLength(50)] - public string Name { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Technology/ReadTechnologyWebModel.cs b/src/DevHive.Web/Models/Technology/ReadTechnologyWebModel.cs deleted file mode 100644 index 94542d7..0000000 --- a/src/DevHive.Web/Models/Technology/ReadTechnologyWebModel.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace DevHive.Web.Models.Technology -{ - public class ReadTechnologyWebModel - { - public Guid Id { get; set; } - - public string Name { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Technology/TechnologyWebModel.cs b/src/DevHive.Web/Models/Technology/TechnologyWebModel.cs deleted file mode 100644 index 6e8273b..0000000 --- a/src/DevHive.Web/Models/Technology/TechnologyWebModel.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; - -namespace DevHive.Web.Models.Technology -{ - public class TechnologyWebModel - { - [NotNull] - [Required] - public Guid Id { get; set; } - } -} diff --git a/src/DevHive.Web/Models/Technology/UpdateTechnologyWebModel.cs b/src/DevHive.Web/Models/Technology/UpdateTechnologyWebModel.cs deleted file mode 100644 index 3e9fe2a..0000000 --- a/src/DevHive.Web/Models/Technology/UpdateTechnologyWebModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; - -namespace DevHive.Web.Models.Technology -{ - public class UpdateTechnologyWebModel - { - [NotNull] - [Required] - [MinLength(3)] - [MaxLength(50)] - public string Name { get; set; } - } -} diff --git a/src/DevHive.Web/Program.cs b/src/DevHive.Web/Program.cs deleted file mode 100644 index 6982da9..0000000 --- a/src/DevHive.Web/Program.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - -namespace DevHive.Web -{ - public class Program - { - private const int HTTP_PORT = 5000; - - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.ConfigureKestrel(opt => opt.ListenLocalhost(HTTP_PORT)); - webBuilder.UseStartup(); - }); - } -} diff --git a/src/DevHive.Web/Properties/launchSettings.json b/src/DevHive.Web/Properties/launchSettings.json deleted file mode 100644 index 2b65d0b..0000000 --- a/src/DevHive.Web/Properties/launchSettings.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:1955", - "sslPort": 44326 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": false, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "DevHive.Web": { - "commandName": "Project", - "dotnetRunMessages": "true", - "launchBrowser": false, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "DevHive.Web Production": { - "commandName": "Project", - "dotnetRunMessages": "true", - "launchBrowser": false, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Production" - } - } - } -} diff --git a/src/DevHive.Web/Startup.cs b/src/DevHive.Web/Startup.cs deleted file mode 100644 index 46521cf..0000000 --- a/src/DevHive.Web/Startup.cs +++ /dev/null @@ -1,70 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using DevHive.Web.Configurations.Extensions; -using Newtonsoft.Json; - -namespace DevHive.Web -{ - public class Startup - { - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - public IConfiguration Configuration { get; } - - // This method gets called by the runtime. Use this method to add services to the container. - public void ConfigureServices(IServiceCollection services) - { - services.AddCors(); - - services.AddControllers() - .AddNewtonsoftJson(x => - { - x.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; - }); - - services.DatabaseConfiguration(Configuration); - services.SwaggerConfiguration(); - services.JWTConfiguration(Configuration); - services.AutoMapperConfiguration(); - services.DependencyInjectionConfiguration(this.Configuration); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - app.UseCors(x => x - .AllowAnyMethod() - .AllowAnyHeader() - .SetIsOriginAllowed(origin => true) // allow any origin - .AllowCredentials()); // allow credentials - - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - app.UseSwaggerConfiguration(); - } - else - { - app.UseHsts(); - app.UseExceptionHandlerMiddlewareConfiguration(); - } - - app.UseDatabaseConfiguration(); - app.UseAutoMapperConfiguration(); - - app.UseEndpoints(endpoints => - { - endpoints.MapControllerRoute( - name: "default", - pattern: "api/{controller}/{action}" - ); - }); - } - } -} diff --git a/src/DevHive.Web/appsettings.json b/src/DevHive.Web/appsettings.json deleted file mode 100644 index bcdcae7..0000000 --- a/src/DevHive.Web/appsettings.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "AppSettings": { - "Secret": "gXfQlU6qpDleFWyimscjYcT3tgFsQg3yoFjcvSLxG56n1Vu2yptdIUq254wlJWjm" - }, - "ConnectionStrings": { - "DEV": "Server=localhost;Port=5432;Database=API;User Id=postgres;Password=;" - }, - "Cloud": { - "cloudName": "devhive", - "apiKey": "488664116365813", - "apiSecret": "" - }, - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - } -} -- cgit v1.2.3