Add server skeleton.

This commit is contained in:
2025-11-13 04:55:13 +00:00
parent 6c01b2128f
commit a942d40849
7 changed files with 103 additions and 0 deletions

View File

@@ -28,5 +28,7 @@
<PackageVersion Include="Pomelo.EntityFrameworkCore.MySql.Json.Microsoft" Version="9.0.0" /> <PackageVersion Include="Pomelo.EntityFrameworkCore.MySql.Json.Microsoft" Version="9.0.0" />
<!-- Build infrastructure --> <!-- Build infrastructure -->
<PackageVersion Include="Packaging.Targets" Version="0.1.189" /> <PackageVersion Include="Packaging.Targets" Version="0.1.189" />
<!-- Unique to Marechai.Server.csproj -->
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Mvc;
namespace Marechai.Server.Controllers;
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries =
[
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
];
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5)
.Select(index => new WeatherForecast
{
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}

View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi"/>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,37 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace Marechai.Server;
public class Program
{
public static void Main(string[] args)
{
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();
}
}

View File

@@ -0,0 +1,12 @@
namespace Marechai.Server;
public class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Directory.Packages.props = Directory.Packages.props Directory.Packages.props = Directory.Packages.props
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Marechai.Server", "Marechai.Server\Marechai.Server.csproj", "{1371F202-4316-4FA4-93A2-8FF0FC136A33}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -27,6 +29,10 @@ Global
{F914D5B9-0C7F-4A40-B187-269B83497AF8}.Debug|Any CPU.Build.0 = Debug|Any CPU {F914D5B9-0C7F-4A40-B187-269B83497AF8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F914D5B9-0C7F-4A40-B187-269B83497AF8}.Release|Any CPU.ActiveCfg = Release|Any CPU {F914D5B9-0C7F-4A40-B187-269B83497AF8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F914D5B9-0C7F-4A40-B187-269B83497AF8}.Release|Any CPU.Build.0 = Release|Any CPU {F914D5B9-0C7F-4A40-B187-269B83497AF8}.Release|Any CPU.Build.0 = Release|Any CPU
{1371F202-4316-4FA4-93A2-8FF0FC136A33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1371F202-4316-4FA4-93A2-8FF0FC136A33}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1371F202-4316-4FA4-93A2-8FF0FC136A33}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1371F202-4316-4FA4-93A2-8FF0FC136A33}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE