diff --git a/.gitignore b/.gitignore index dfcfd56..67fa4e0 100644 --- a/.gitignore +++ b/.gitignore @@ -348,3 +348,4 @@ MigrationBackup/ # Ionide (cross platform F# VS Code tools) working folder .ionide/ +/TheBookWizard.Services.Api/appsettings.Development.json diff --git a/TheBookWizard.Services.Api/Program.cs b/TheBookWizard.Services.Api/Program.cs new file mode 100644 index 0000000..c4ae3c5 --- /dev/null +++ b/TheBookWizard.Services.Api/Program.cs @@ -0,0 +1,21 @@ +// ----------------------------------------------------------------------- +// Copyright (c) MumsWhoCode. All rights reserved. +// ----------------------------------------------------------------------- + +namespace TheBookWizard.Services.Api +{ + public class Program + { + public static void Main(string[] args) => + CreateHostBuilder(args).Build().Run(); + + public static IHostBuilder CreateHostBuilder(string[] args) + { + return Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); + } + } +} \ No newline at end of file diff --git a/TheBookWizard.Services.Api/Properties/launchSettings.json b/TheBookWizard.Services.Api/Properties/launchSettings.json new file mode 100644 index 0000000..4e8cdc1 --- /dev/null +++ b/TheBookWizard.Services.Api/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:43005", + "sslPort": 44364 + } + }, + "profiles": { + "TheBookWizard.Services.Api": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7195;http://localhost:5195", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/TheBookWizard.Services.Api/Startup.cs b/TheBookWizard.Services.Api/Startup.cs new file mode 100644 index 0000000..a64fc68 --- /dev/null +++ b/TheBookWizard.Services.Api/Startup.cs @@ -0,0 +1,55 @@ +// ----------------------------------------------------------------------- +// Copyright (c) MumsWhoCode. All rights reserved. +// ----------------------------------------------------------------------- + +using Microsoft.OpenApi.Models; + +namespace TheBookWizard.Services.Api +{ + public class Startup + { + public Startup(IConfiguration configuration) => + Configuration = configuration; + + public IConfiguration Configuration { get; } + + public void ConfigureServices(IServiceCollection services) + { + services.AddControllers(); + + services.AddSwaggerGen(options => + { + var openApiInfo = new OpenApiInfo + { + Title = "TheBookWizard.Services.Api", + Version = "v1" + }; + + options.SwaggerDoc( + name: "v1", + info: openApiInfo); + }); + } + + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + app.UseSwagger(); + + app.UseSwaggerUI(options => + { + options.SwaggerEndpoint( + url: "/swagger/v1/swagger.json", + name: "TheBookWizard.ServicesApi v1"); + }); + } + + app.UseHttpsRedirection(); + app.UseRouting(); + app.UseAuthorization(); + app.UseEndpoints(endpoints => endpoints.MapControllers()); + } + } +} \ No newline at end of file diff --git a/TheBookWizard.Services.Api/TheBookWizard.Services.Api.csproj b/TheBookWizard.Services.Api/TheBookWizard.Services.Api.csproj new file mode 100644 index 0000000..d9092ed --- /dev/null +++ b/TheBookWizard.Services.Api/TheBookWizard.Services.Api.csproj @@ -0,0 +1,18 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + diff --git a/TheBookWizard.Services.Api/appsettings.json b/TheBookWizard.Services.Api/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/TheBookWizard.Services.Api/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/TheBookWizard.Services.sln b/TheBookWizard.Services.sln index e1c60a4..51c3605 100644 --- a/TheBookWizard.Services.sln +++ b/TheBookWizard.Services.sln @@ -10,6 +10,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\..\SCMS.Services\.editorconfig = ..\..\SCMS.Services\.editorconfig EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheBookWizard.Services.Api", "TheBookWizard.Services.Api\TheBookWizard.Services.Api.csproj", "{E1FA81DF-912A-4213-9DC8-DB0BE9804DF6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -20,6 +22,10 @@ Global {D6C6E69D-53F2-4D58-8279-19AC77BE9A87}.Debug|Any CPU.Build.0 = Debug|Any CPU {D6C6E69D-53F2-4D58-8279-19AC77BE9A87}.Release|Any CPU.ActiveCfg = Release|Any CPU {D6C6E69D-53F2-4D58-8279-19AC77BE9A87}.Release|Any CPU.Build.0 = Release|Any CPU + {E1FA81DF-912A-4213-9DC8-DB0BE9804DF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E1FA81DF-912A-4213-9DC8-DB0BE9804DF6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E1FA81DF-912A-4213-9DC8-DB0BE9804DF6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E1FA81DF-912A-4213-9DC8-DB0BE9804DF6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE