From c58d07731c9022740ec062a6efcd7546309e80a5 Mon Sep 17 00:00:00 2001 From: "m.zargarov" Date: Mon, 28 Oct 2024 00:25:51 +0400 Subject: [PATCH] add dev --- .vscode/settings.json | 3 ++ Cloud.sln | 22 +++++++++++++ Cloud/Cloud.csproj | 13 ++++++++ .../Controllers/WeatherForecastController.cs | 32 +++++++++++++++++++ Cloud/Program.cs | 25 +++++++++++++++ Cloud/Properties/launchSettings.json | 31 ++++++++++++++++++ Cloud/WeatherForecast.cs | 12 +++++++ Cloud/appsettings.Development.json | 8 +++++ Cloud/appsettings.json | 9 ++++++ docker-compose.yml | 16 ++++++++++ 10 files changed, 171 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 Cloud.sln create mode 100644 Cloud/Cloud.csproj create mode 100644 Cloud/Controllers/WeatherForecastController.cs create mode 100644 Cloud/Program.cs create mode 100644 Cloud/Properties/launchSettings.json create mode 100644 Cloud/WeatherForecast.cs create mode 100644 Cloud/appsettings.Development.json create mode 100644 Cloud/appsettings.json create mode 100644 docker-compose.yml diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c17f084 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "dotnet.defaultSolution": "Cloud.sln" +} \ No newline at end of file diff --git a/Cloud.sln b/Cloud.sln new file mode 100644 index 0000000..215c0ae --- /dev/null +++ b/Cloud.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cloud", "Cloud\Cloud.csproj", "{D279AAA9-D4F8-4C7B-B34D-44A7429C87AA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D279AAA9-D4F8-4C7B-B34D-44A7429C87AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D279AAA9-D4F8-4C7B-B34D-44A7429C87AA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D279AAA9-D4F8-4C7B-B34D-44A7429C87AA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D279AAA9-D4F8-4C7B-B34D-44A7429C87AA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Cloud/Cloud.csproj b/Cloud/Cloud.csproj new file mode 100644 index 0000000..2c33b1c --- /dev/null +++ b/Cloud/Cloud.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/Cloud/Controllers/WeatherForecastController.cs b/Cloud/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..5f76bcd --- /dev/null +++ b/Cloud/Controllers/WeatherForecastController.cs @@ -0,0 +1,32 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Cloud.Controllers; + +[ApiController] +[Route("[controller]")] +public class WeatherForecastController : ControllerBase +{ + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateTime.Now.AddDays(index), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } +} diff --git a/Cloud/Program.cs b/Cloud/Program.cs new file mode 100644 index 0000000..48863a6 --- /dev/null +++ b/Cloud/Program.cs @@ -0,0 +1,25 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddControllers(); +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); diff --git a/Cloud/Properties/launchSettings.json b/Cloud/Properties/launchSettings.json new file mode 100644 index 0000000..2e9e32f --- /dev/null +++ b/Cloud/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:43967", + "sslPort": 44304 + } + }, + "profiles": { + "Cloud": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7113;http://localhost:5124", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Cloud/WeatherForecast.cs b/Cloud/WeatherForecast.cs new file mode 100644 index 0000000..d787653 --- /dev/null +++ b/Cloud/WeatherForecast.cs @@ -0,0 +1,12 @@ +namespace Cloud; + +public class WeatherForecast +{ + public DateTime Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } +} diff --git a/Cloud/appsettings.Development.json b/Cloud/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/Cloud/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Cloud/appsettings.json b/Cloud/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/Cloud/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..6915ce1 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +services: + postgres: + image: postgres:14 + container_name: cucumber_database + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: 12345 + POSTGRES_DB: main_database + ports: + - "5438:5432" + volumes: + - postgres_data:/var/lib/postgresql/data + +volumes: + postgres_data: + driver: local \ No newline at end of file