diff --git a/.gitignore b/.gitignore index c7edd36..4970f01 100644 --- a/.gitignore +++ b/.gitignore @@ -104,6 +104,7 @@ appsettings.Production.json *.Development.json *.Production.json *.Staging.json +*.env # Ignore IDE-specific files .vscode/ diff --git a/README.md b/README.md index 9f70840..e69de29 100644 --- a/README.md +++ b/README.md @@ -1,51 +0,0 @@ -# Portfolio Backend - -This is the backend for the portfolio project, built with .NET 8.0. - -## Project Structure - -``` -backend/ -├── src/ -│ └── PortfolioBackend/ -│ ├── Controllers/ -│ ├── Models/ -│ ├── Repositories/ -│ ├── Services/ -│ ├── Migrations/ -│ ├── Program.cs -│ ├── appsettings.json -│ ├── appsettings.Development.json -│ └── PortfolioBackend.csproj -├── tests/ -│ └── PortfolioBackend.Tests/ -│ ├── Controllers/ -│ ├── Models/ -│ ├── Repositories/ -│ ├── Services/ -│ └── PortfolioBackend.Tests.csproj -├── docker/ -│ ├── Dockerfile -│ └── docker-compose.yml -├── .gitignore -└── README.md -``` - -## Setup - -1. Ensure you have .NET 8.0 SDK installed. -2. Clone this repository. -3. Navigate to the `src/PortfolioBackend` directory. -4. Run `dotnet restore` to restore the NuGet packages. -5. Run `dotnet run` to start the application. - -## Running with Docker - -1. Ensure you have Docker and Docker Compose installed. -2. Navigate to the `docker` directory. -3. Run `docker-compose up --build` to build and start the containers. - -## Running Tests - -1. Navigate to the `tests/PortfolioBackend.Tests` directory. -2. Run `dotnet test` to run the unit tests. diff --git a/src/Microservices/Titan.ProjectService/.editorconfig b/src/Microservices/Titan.ProjectService/.editorconfig new file mode 100644 index 0000000..79b63c3 --- /dev/null +++ b/src/Microservices/Titan.ProjectService/.editorconfig @@ -0,0 +1,70 @@ +# Top-most EditorConfig file +root = true + +# All files +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +# C# files +[*.cs] +# New line preferences +csharp_new_line_before_open_brace = none +csharp_new_line_before_else = false +csharp_new_line_before_catch = false +csharp_new_line_before_finally = false +csharp_new_line_before_members_in_object_initializers = false +csharp_new_line_before_members_in_anonymous_types = false +csharp_new_line_between_query_expression_clauses = false + +# Indentation preferences +csharp_indent_case_contents = true +csharp_indent_switch_labels = true +csharp_indent_labels = flush_left + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_around_binary_operators = before_and_after +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false + +# Wrapping preferences +csharp_preserve_single_line_statements = true +csharp_preserve_single_line_blocks = true + +# Expression-bodied members +csharp_style_expression_bodied_methods = false:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_operators = false:silent +csharp_style_expression_bodied_properties = true:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_accessors = true:silent + +# Pattern matching preferences +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion + +# Null-checking preferences +csharp_style_throw_expression = true:suggestion +csharp_style_conditional_delegate_call = true:suggestion + +# Modifier preferences +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion + +# Expression-level preferences +csharp_prefer_braces = true:silent +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_pattern_local_over_anonymous_function = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion \ No newline at end of file diff --git a/src/Microservices/Titan.ProjectService/Titan.ProjectService.API/Program.cs b/src/Microservices/Titan.ProjectService/Titan.ProjectService.API/Program.cs new file mode 100644 index 0000000..a21a6a4 --- /dev/null +++ b/src/Microservices/Titan.ProjectService/Titan.ProjectService.API/Program.cs @@ -0,0 +1,43 @@ +using DotNetEnv; +using Microsoft.EntityFrameworkCore; + +using Titan.ProjectService.Infrastructure.Data; + +Env.Load(); // Load environment variables from .env file + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +builder.Services.AddControllers(); + +// Configure DbContext +builder.Services.AddDbContext(options => + options.UseNpgsql(Environment.GetEnvironmentVariable("POSTGRES_CONNECTION_STRING"))); + +// Configure Minio client +builder.Services.AddSingleton(sp => + new Minio.MinioClient() + .WithEndpoint(Environment.GetEnvironmentVariable("MINIO_ENDPOINT")) + .WithCredentials( + Environment.GetEnvironmentVariable("MINIO_ACCESS_KEY"), + Environment.GetEnvironmentVariable("MINIO_SECRET_KEY")) + .Build()); + +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); +app.UseAuthorization(); +app.MapControllers(); + +app.Run(); \ No newline at end of file diff --git a/src/Titan.API/Properties/launchSettings.json b/src/Microservices/Titan.ProjectService/Titan.ProjectService.API/Properties/launchSettings.json similarity index 79% rename from src/Titan.API/Properties/launchSettings.json rename to src/Microservices/Titan.ProjectService/Titan.ProjectService.API/Properties/launchSettings.json index 904d71b..cb5e6f7 100644 --- a/src/Titan.API/Properties/launchSettings.json +++ b/src/Microservices/Titan.ProjectService/Titan.ProjectService.API/Properties/launchSettings.json @@ -1,41 +1,41 @@ -{ - "$schema": "http://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:22924", - "sslPort": 44301 - } - }, - "profiles": { - "http": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": true, - "launchUrl": "swagger", - "applicationUrl": "http://localhost:5221", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "https": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": true, - "launchUrl": "swagger", - "applicationUrl": "https://localhost:7052;http://localhost:5221", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "swagger", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:46093", + "sslPort": 44397 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5282", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7109;http://localhost:5282", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/Microservices/Titan.ProjectService/Titan.ProjectService.API/Titan.ProjectService.API.csproj b/src/Microservices/Titan.ProjectService/Titan.ProjectService.API/Titan.ProjectService.API.csproj new file mode 100644 index 0000000..86245d3 --- /dev/null +++ b/src/Microservices/Titan.ProjectService/Titan.ProjectService.API/Titan.ProjectService.API.csproj @@ -0,0 +1,26 @@ + + + + net8.0 + enable + enable + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + + diff --git a/src/Microservices/Titan.ProjectService/Titan.ProjectService.API/Titan.ProjectService.API.http b/src/Microservices/Titan.ProjectService/Titan.ProjectService.API/Titan.ProjectService.API.http new file mode 100644 index 0000000..701920a --- /dev/null +++ b/src/Microservices/Titan.ProjectService/Titan.ProjectService.API/Titan.ProjectService.API.http @@ -0,0 +1,4 @@ +@Titan.ProjectService.API_HostAddress = http://localhost:5282 + + +### diff --git a/src/Titan.API/appsettings.json b/src/Microservices/Titan.ProjectService/Titan.ProjectService.API/appsettings.json similarity index 94% rename from src/Titan.API/appsettings.json rename to src/Microservices/Titan.ProjectService/Titan.ProjectService.API/appsettings.json index 4d56694..10f68b8 100644 --- a/src/Titan.API/appsettings.json +++ b/src/Microservices/Titan.ProjectService/Titan.ProjectService.API/appsettings.json @@ -1,9 +1,9 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - }, - "AllowedHosts": "*" -} +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/src/Microservices/Titan.ProjectService/Titan.ProjectService.Core/Entities/Project.cs b/src/Microservices/Titan.ProjectService/Titan.ProjectService.Core/Entities/Project.cs new file mode 100644 index 0000000..538e2b9 --- /dev/null +++ b/src/Microservices/Titan.ProjectService/Titan.ProjectService.Core/Entities/Project.cs @@ -0,0 +1,6 @@ +namespace Titan.ProjectService.Core.Entities; + +public class Project +{ + public int Id +} \ No newline at end of file diff --git a/src/Titan.Core/Titan.Core.csproj b/src/Microservices/Titan.ProjectService/Titan.ProjectService.Core/Titan.ProjectService.Core.csproj similarity index 95% rename from src/Titan.Core/Titan.Core.csproj rename to src/Microservices/Titan.ProjectService/Titan.ProjectService.Core/Titan.ProjectService.Core.csproj index bb23fb7..fa71b7a 100644 --- a/src/Titan.Core/Titan.Core.csproj +++ b/src/Microservices/Titan.ProjectService/Titan.ProjectService.Core/Titan.ProjectService.Core.csproj @@ -1,9 +1,9 @@ - - - - net8.0 - enable - enable - - - + + + + net8.0 + enable + enable + + + diff --git a/src/Microservices/Titan.ProjectService/Titan.ProjectService.Infrastructure/Data/ProjectDbContext.cs b/src/Microservices/Titan.ProjectService/Titan.ProjectService.Infrastructure/Data/ProjectDbContext.cs new file mode 100644 index 0000000..5d2d472 --- /dev/null +++ b/src/Microservices/Titan.ProjectService/Titan.ProjectService.Infrastructure/Data/ProjectDbContext.cs @@ -0,0 +1,9 @@ +using Microsoft.EntityFrameworkCore; + +namespace Titan.ProjectService.Infrastructure.Data; + +public class ProjectDbContext : ProjectDbContext +{ + public ProjectDbContext(DbContextOptions options) : base(options) { } + public DbSet Projects { get; set; } +} \ No newline at end of file diff --git a/src/Microservices/Titan.ProjectService/Titan.ProjectService.Infrastructure/Titan.ProjectService.Infrastructure.csproj b/src/Microservices/Titan.ProjectService/Titan.ProjectService.Infrastructure/Titan.ProjectService.Infrastructure.csproj new file mode 100644 index 0000000..2de65b5 --- /dev/null +++ b/src/Microservices/Titan.ProjectService/Titan.ProjectService.Infrastructure/Titan.ProjectService.Infrastructure.csproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + net8.0 + enable + enable + + + diff --git a/src/Microservices/Titan.ProjectService/Titan.ProjectService.Tests/GlobalUsings.cs b/src/Microservices/Titan.ProjectService/Titan.ProjectService.Tests/GlobalUsings.cs new file mode 100644 index 0000000..8c927eb --- /dev/null +++ b/src/Microservices/Titan.ProjectService/Titan.ProjectService.Tests/GlobalUsings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file diff --git a/src/Microservices/Titan.ProjectService/Titan.ProjectService.Tests/Titan.ProjectService.Tests.csproj b/src/Microservices/Titan.ProjectService/Titan.ProjectService.Tests/Titan.ProjectService.Tests.csproj new file mode 100644 index 0000000..22b0134 --- /dev/null +++ b/src/Microservices/Titan.ProjectService/Titan.ProjectService.Tests/Titan.ProjectService.Tests.csproj @@ -0,0 +1,25 @@ + + + + net8.0 + enable + enable + + false + true + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + diff --git a/src/Microservices/Titan.ProjectService/Titan.ProjectService.Tests/UnitTest1.cs b/src/Microservices/Titan.ProjectService/Titan.ProjectService.Tests/UnitTest1.cs new file mode 100644 index 0000000..493ec4c --- /dev/null +++ b/src/Microservices/Titan.ProjectService/Titan.ProjectService.Tests/UnitTest1.cs @@ -0,0 +1,10 @@ +namespace Titan.ProjectService.Tests; + +public class UnitTest1 +{ + [Fact] + public void Test1() + { + + } +} \ No newline at end of file diff --git a/src/Titan.API/Program.cs b/src/Titan.API/Program.cs deleted file mode 100644 index e69de29..0000000 diff --git a/src/Titan.API/Titan.API.csproj b/src/Titan.API/Titan.API.csproj deleted file mode 100644 index a6c9074..0000000 --- a/src/Titan.API/Titan.API.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - net8.0 - enable - enable - - - - - - - - - - - - - diff --git a/src/Titan.API/Titan.API.http b/src/Titan.API/Titan.API.http deleted file mode 100644 index 7e07c2a..0000000 --- a/src/Titan.API/Titan.API.http +++ /dev/null @@ -1,6 +0,0 @@ -@Titan.API_HostAddress = http://localhost:5221 - -GET {{Titan.API_HostAddress}}/weatherforecast/ -Accept: application/json - -### diff --git a/src/Titan.Application/Titan.Application.csproj b/src/Titan.Application/Titan.Application.csproj deleted file mode 100644 index 35385ce..0000000 --- a/src/Titan.Application/Titan.Application.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - net8.0 - enable - enable - - - diff --git a/src/Titan.Infrastructure/Titan.Infrastructure.csproj b/src/Titan.Infrastructure/Titan.Infrastructure.csproj deleted file mode 100644 index be71bd4..0000000 --- a/src/Titan.Infrastructure/Titan.Infrastructure.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - net8.0 - enable - enable - - -