From 1b9b99c8e5369b7f5506e36e1dd6e47012307f9b Mon Sep 17 00:00:00 2001 From: Nickromancer Date: Tue, 15 Nov 2022 12:29:06 +0100 Subject: [PATCH] REST API skeleton --- Project.MinimalAPI/TodoAPI/Program.cs | 29 +++++++++++++++++++ .../TodoAPI/Properties/launchSettings.json | 28 ++++++++++++++++++ Project.MinimalAPI/TodoAPI/TodoAPI.csproj | 16 ++++++++++ .../TodoAPI/appsettings.Development.json | 8 +++++ Project.MinimalAPI/TodoAPI/appsettings.json | 9 ++++++ 5 files changed, 90 insertions(+) create mode 100644 Project.MinimalAPI/TodoAPI/Program.cs create mode 100644 Project.MinimalAPI/TodoAPI/Properties/launchSettings.json create mode 100644 Project.MinimalAPI/TodoAPI/TodoAPI.csproj create mode 100644 Project.MinimalAPI/TodoAPI/appsettings.Development.json create mode 100644 Project.MinimalAPI/TodoAPI/appsettings.json diff --git a/Project.MinimalAPI/TodoAPI/Program.cs b/Project.MinimalAPI/TodoAPI/Program.cs new file mode 100644 index 0000000..2594996 --- /dev/null +++ b/Project.MinimalAPI/TodoAPI/Program.cs @@ -0,0 +1,29 @@ +var builder = WebApplication.CreateBuilder(args); + +/* builder.Services.AddDbContext(options => options.UseSqlServer(builder.Configuration.GetConnectionString("Project"))); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); */ + + +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} +app.UseHttpsRedirection(); + +/* var commitAuthor = app.MapGroup("/commitAuthor").WithOpenApi(); +var commitFrequency = app.MapGroup("/commitFrequency").WithOpenApi(); */ + +app.MapGet("/", () => "Hello World!"); + +//app.MapGet("/{RepositoryPath}", async (string path, UserRepo repository) => await repository.FindAsync()); + + app.Run(); diff --git a/Project.MinimalAPI/TodoAPI/Properties/launchSettings.json b/Project.MinimalAPI/TodoAPI/Properties/launchSettings.json new file mode 100644 index 0000000..d876668 --- /dev/null +++ b/Project.MinimalAPI/TodoAPI/Properties/launchSettings.json @@ -0,0 +1,28 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:47606", + "sslPort": 44345 + } + }, + "profiles": { + "TodoAPI": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7236;http://localhost:5058", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Project.MinimalAPI/TodoAPI/TodoAPI.csproj b/Project.MinimalAPI/TodoAPI/TodoAPI.csproj new file mode 100644 index 0000000..bc27e0d --- /dev/null +++ b/Project.MinimalAPI/TodoAPI/TodoAPI.csproj @@ -0,0 +1,16 @@ + + + + net6.0 + enable + enable + true + + + + + + + + + diff --git a/Project.MinimalAPI/TodoAPI/appsettings.Development.json b/Project.MinimalAPI/TodoAPI/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/Project.MinimalAPI/TodoAPI/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Project.MinimalAPI/TodoAPI/appsettings.json b/Project.MinimalAPI/TodoAPI/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/Project.MinimalAPI/TodoAPI/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}