Initial commit of Jetbrains template
This commit is contained in:
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
bin/
|
||||||
|
obj/
|
||||||
|
/packages/
|
||||||
|
riderModule.iml
|
||||||
|
/_ReSharper.Caches/
|
||||||
16
SDG-Backend-Amberjack.sln
Normal file
16
SDG-Backend-Amberjack.sln
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDG-Backend-Amberjack", "SDG-Backend-Amberjack\SDG-Backend-Amberjack.csproj", "{6A303E34-4088-4B56-B90C-57D7B2EC0378}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{6A303E34-4088-4B56-B90C-57D7B2EC0378}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{6A303E34-4088-4B56-B90C-57D7B2EC0378}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{6A303E34-4088-4B56-B90C-57D7B2EC0378}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{6A303E34-4088-4B56-B90C-57D7B2EC0378}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
47
SDG-Backend-Amberjack/Program.cs
Normal file
47
SDG-Backend-Amberjack/Program.cs
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using Microsoft.AspNetCore.Http.HttpResults;
|
||||||
|
|
||||||
|
var builder = WebApplication.CreateSlimBuilder(args);
|
||||||
|
|
||||||
|
builder.Services.ConfigureHttpJsonOptions(options =>
|
||||||
|
{
|
||||||
|
options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
||||||
|
builder.Services.AddOpenApi();
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
if (app.Environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
app.MapOpenApi();
|
||||||
|
}
|
||||||
|
|
||||||
|
Todo[] sampleTodos =
|
||||||
|
[
|
||||||
|
new(1, "Walk the dog"),
|
||||||
|
new(2, "Do the dishes", DateOnly.FromDateTime(DateTime.Now)),
|
||||||
|
new(3, "Do the laundry", DateOnly.FromDateTime(DateTime.Now.AddDays(1))),
|
||||||
|
new(4, "Clean the bathroom"),
|
||||||
|
new(5, "Clean the car", DateOnly.FromDateTime(DateTime.Now.AddDays(2)))
|
||||||
|
];
|
||||||
|
|
||||||
|
var todosApi = app.MapGroup("/todos");
|
||||||
|
todosApi.MapGet("/", () => sampleTodos)
|
||||||
|
.WithName("GetTodos");
|
||||||
|
|
||||||
|
todosApi.MapGet("/{id}", Results<Ok<Todo>, NotFound> (int id) =>
|
||||||
|
sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo
|
||||||
|
? TypedResults.Ok(todo)
|
||||||
|
: TypedResults.NotFound())
|
||||||
|
.WithName("GetTodoById");
|
||||||
|
|
||||||
|
app.Run();
|
||||||
|
|
||||||
|
public record Todo(int Id, string? Title, DateOnly? DueBy = null, bool IsComplete = false);
|
||||||
|
|
||||||
|
[JsonSerializable(typeof(Todo[]))]
|
||||||
|
internal partial class AppJsonSerializerContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
||||||
15
SDG-Backend-Amberjack/Properties/launchSettings.json
Normal file
15
SDG-Backend-Amberjack/Properties/launchSettings.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
|
"profiles": {
|
||||||
|
"http": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "todos",
|
||||||
|
"applicationUrl": "http://localhost:5072",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
SDG-Backend-Amberjack/SDG-Backend-Amberjack.csproj
Normal file
16
SDG-Backend-Amberjack/SDG-Backend-Amberjack.csproj
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<RootNamespace>SDG_Backend_Amberjack</RootNamespace>
|
||||||
|
<InvariantGlobalization>true</InvariantGlobalization>
|
||||||
|
<PublishAot>true</PublishAot>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.1"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
11
SDG-Backend-Amberjack/SDG-Backend-Amberjack.http
Normal file
11
SDG-Backend-Amberjack/SDG-Backend-Amberjack.http
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
@SDG_Backend_Amberjack_HostAddress = http://localhost:5072
|
||||||
|
|
||||||
|
GET {{SDG_Backend_Amberjack_HostAddress}}/todos/
|
||||||
|
Accept: application/json
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
GET {{SDG_Backend_Amberjack_HostAddress}}/todos/1
|
||||||
|
Accept: application/json
|
||||||
|
|
||||||
|
###
|
||||||
8
SDG-Backend-Amberjack/appsettings.Development.json
Normal file
8
SDG-Backend-Amberjack/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
SDG-Backend-Amberjack/appsettings.json
Normal file
9
SDG-Backend-Amberjack/appsettings.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user