Add project files.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace TURN.Services.Chess.Controllers
|
||||
{
|
||||
[Route("/[controller]")]
|
||||
[ApiController]
|
||||
public class TurnController : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Тестовый гет.
|
||||
/// </summary>
|
||||
[HttpGet("test/{param}")]
|
||||
public ActionResult<string> Get(string param)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Ok(param);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(500, $"Internal server error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
|
||||
WORKDIR /app
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
|
||||
WORKDIR /src
|
||||
COPY ["TURN.Services.Chess/TURN.Services.Chess.csproj", "TURN.Services.Chess/"]
|
||||
COPY ["TURN.Libraries.Core/TURN.Libraries.Core.csproj", "TURN.Libraries.Core/"]
|
||||
RUN dotnet restore "TURN.Services.Chess/TURN.Services.Chess.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/TURN.Services.Chess"
|
||||
RUN dotnet build "TURN.Services.Chess.csproj" -c Release -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
RUN dotnet publish "TURN.Services.Chess.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "TURN.Services.Chess.dll"]
|
||||
@@ -0,0 +1,26 @@
|
||||
using Microsoft.AspNetCore;
|
||||
using TURN.Services.Chess;
|
||||
using LoggerFactory = TURN.Libraries.Core.LoggerFactory;
|
||||
|
||||
NLog.Logger logger = LoggerFactory.GetLogger();
|
||||
logger.Info("Chess app starting.");
|
||||
|
||||
try
|
||||
{
|
||||
IWebHost host = BuildWebHost(args);
|
||||
host.Run();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex);
|
||||
}
|
||||
|
||||
IWebHost BuildWebHost(string[] args) => WebHost
|
||||
.CreateDefaultBuilder(args)
|
||||
.CaptureStartupErrors(false)
|
||||
.ConfigureServices(services =>
|
||||
{
|
||||
_ = services.AddSingleton(logger);
|
||||
})
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:5110"
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"Docker": {
|
||||
"commandName": "Docker",
|
||||
"publishAllPorts": true
|
||||
}
|
||||
},
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:12777",
|
||||
"sslPort": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using System.Reflection;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace TURN.Services.Chess
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
ConfigureSwagger(services);
|
||||
_ = services.AddControllers();
|
||||
_ = services.AddControllers().AddNewtonsoftJson(jsonOptions =>
|
||||
{
|
||||
jsonOptions.SerializerSettings.Converters.Add(new StringEnumConverter());
|
||||
});
|
||||
//_ = services.AddDbContext<ModelBaseContext>(
|
||||
// options => options.UseSqlServer(Environment.GetEnvironmentVariable("DB")));
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
_ = app.UseRouting();
|
||||
_ = app.UseSwagger();
|
||||
_ = app.UseSwaggerUI();
|
||||
_ = app.UseEndpoints(endpoints =>
|
||||
{
|
||||
_ = endpoints.MapControllers();
|
||||
_ = endpoints.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller}/{action}");
|
||||
_ = endpoints.MapSwagger();
|
||||
});
|
||||
}
|
||||
|
||||
private void ConfigureSwagger(IServiceCollection services)
|
||||
{
|
||||
_ = services.AddSwaggerGen(options =>
|
||||
{
|
||||
options.SwaggerDoc("v1", new OpenApiInfo
|
||||
{
|
||||
Title = "TURN.Api.Swagger",
|
||||
Version = "v1"
|
||||
});
|
||||
string xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
||||
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
|
||||
});
|
||||
_ = services.AddSwaggerGenNewtonsoftSupport();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.8" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="NLog" Version="5.2.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="6.5.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.5.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TURN.Libraries.Core\TURN.Libraries.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
Reference in New Issue
Block a user