From 736f15c1f5417842dd078377df9b3665028a38f6 Mon Sep 17 00:00:00 2001 From: Matt Dunlap Date: Wed, 18 Dec 2024 22:22:21 -0500 Subject: [PATCH] Add Api project --- Sheltered.sln | 14 +++++++++++ src/Api/Api.csproj | 16 +++++++++++++ src/Api/Api.http | 3 +++ src/Api/Program.cs | 27 +++++++++++++++++++++ src/Api/Properties/launchSettings.json | 23 ++++++++++++++++++ src/Api/appsettings.Development.json | 8 +++++++ src/Api/appsettings.json | 9 +++++++ tests/Api.UnitTests/Api.UnitTests.csproj | 30 ++++++++++++++++++++++++ 8 files changed, 130 insertions(+) create mode 100644 src/Api/Api.csproj create mode 100644 src/Api/Api.http create mode 100644 src/Api/Program.cs create mode 100644 src/Api/Properties/launchSettings.json create mode 100644 src/Api/appsettings.Development.json create mode 100644 src/Api/appsettings.json create mode 100644 tests/Api.UnitTests/Api.UnitTests.csproj diff --git a/Sheltered.sln b/Sheltered.sln index 81363dc..70a0ef3 100644 --- a/Sheltered.sln +++ b/Sheltered.sln @@ -15,6 +15,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Web", "src\Web\Web.csproj", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Web.UnitTests", "tests\Web.UnitTests\Web.UnitTests.csproj", "{55DBB2B9-77F8-4228-B1D5-E8CD278AFBAA}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Api", "src\Api\Api.csproj", "{9BB9632A-F586-4503-8230-AAE5B42D697C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Api.UnitTests", "tests\Api.UnitTests\Api.UnitTests.csproj", "{341719AE-7C67-4C1F-82EF-2E3E9ADEC4AC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -40,11 +44,21 @@ Global {55DBB2B9-77F8-4228-B1D5-E8CD278AFBAA}.Debug|Any CPU.Build.0 = Debug|Any CPU {55DBB2B9-77F8-4228-B1D5-E8CD278AFBAA}.Release|Any CPU.ActiveCfg = Release|Any CPU {55DBB2B9-77F8-4228-B1D5-E8CD278AFBAA}.Release|Any CPU.Build.0 = Release|Any CPU + {9BB9632A-F586-4503-8230-AAE5B42D697C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9BB9632A-F586-4503-8230-AAE5B42D697C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9BB9632A-F586-4503-8230-AAE5B42D697C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9BB9632A-F586-4503-8230-AAE5B42D697C}.Release|Any CPU.Build.0 = Release|Any CPU + {341719AE-7C67-4C1F-82EF-2E3E9ADEC4AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {341719AE-7C67-4C1F-82EF-2E3E9ADEC4AC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {341719AE-7C67-4C1F-82EF-2E3E9ADEC4AC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {341719AE-7C67-4C1F-82EF-2E3E9ADEC4AC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {BFC32006-CC1E-4B47-B4E0-F8B9F154CE59} = {D774B9EF-9B46-4B74-BE9A-64433F42B21F} {A50BA0DE-5F65-40F8-8483-3DB1DF198790} = {45516425-988D-4261-8C46-19EC5D946EAE} {BFDF54CF-35D7-4C86-86F8-8F9230CCC899} = {D774B9EF-9B46-4B74-BE9A-64433F42B21F} {55DBB2B9-77F8-4228-B1D5-E8CD278AFBAA} = {45516425-988D-4261-8C46-19EC5D946EAE} + {9BB9632A-F586-4503-8230-AAE5B42D697C} = {D774B9EF-9B46-4B74-BE9A-64433F42B21F} + {341719AE-7C67-4C1F-82EF-2E3E9ADEC4AC} = {45516425-988D-4261-8C46-19EC5D946EAE} EndGlobalSection EndGlobal diff --git a/src/Api/Api.csproj b/src/Api/Api.csproj new file mode 100644 index 0000000..0138eba --- /dev/null +++ b/src/Api/Api.csproj @@ -0,0 +1,16 @@ + + + + net9.0 + enable + disable + true + true + CS1591 + + + + + + + diff --git a/src/Api/Api.http b/src/Api/Api.http new file mode 100644 index 0000000..66b5013 --- /dev/null +++ b/src/Api/Api.http @@ -0,0 +1,3 @@ +@Api_HostAddress = http://localhost:5108 + +### diff --git a/src/Api/Program.cs b/src/Api/Program.cs new file mode 100644 index 0000000..5f47be9 --- /dev/null +++ b/src/Api/Program.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddControllers(); +// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi +builder.Services.AddOpenApi(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.MapOpenApi(); +} + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); diff --git a/src/Api/Properties/launchSettings.json b/src/Api/Properties/launchSettings.json new file mode 100644 index 0000000..6182880 --- /dev/null +++ b/src/Api/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://localhost:5108", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:7097;http://localhost:5108", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/Api/appsettings.Development.json b/src/Api/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/src/Api/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/src/Api/appsettings.json b/src/Api/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/src/Api/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/tests/Api.UnitTests/Api.UnitTests.csproj b/tests/Api.UnitTests/Api.UnitTests.csproj new file mode 100644 index 0000000..cdd41b4 --- /dev/null +++ b/tests/Api.UnitTests/Api.UnitTests.csproj @@ -0,0 +1,30 @@ + + + + net9.0 + latest + false + enable + disable + true + false + CS1591 + + + + + + + + + + + + + + + + + + +