commit 7b77e7b774be3bcb866a25e8e4458f84bad96eee Author: ryzij Date: Fri Aug 28 03:54:53 2026 +0300 First commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0064acd --- /dev/null +++ b/.gitignore @@ -0,0 +1,86 @@ +# Build results +[Dd]ebug/ +[Rr]elease/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ +publish/ + +# Visual Studio +.vs/ +*.user +*.suo +*.userosscache +*.sln.docstates + +# Rider / JetBrains +.idea/ +*.sln.iml + +# VS Code +.vscode/ + +# ASP.NET Core +appsettings.Development.json +appsettings.Local.json + +# Environment variables +.env +#.env.* + +# Logs +logs/ +*.log + +# NuGet +*.nupkg +packages/ +!packages/build/ + +# Entity Framework +*.db +*.db-shm +*.db-wal + +# SQLite +*.sqlite +*.sqlite3 + +# OS files +.DS_Store +Thumbs.db + +# Node modules +node_modules/ + +# Coverage / tests +coverage/ +TestResults/ + +# Docker +docker-compose.yml +docker-compose.override.yml + +# Generated files +*.cache +*.tmp +*.temp + +# Publish output +wwwroot/dist/ +wwwroot/build/ + +# Secrets +secrets.json + +# Certificates +*.pfx +*.pem +*.key + +# Resharper +_ReSharper*/ +*.DotSettings.user diff --git a/AMessanger.API/AMessanger.API.csproj b/AMessanger.API/AMessanger.API.csproj new file mode 100644 index 0000000..8ba9f41 --- /dev/null +++ b/AMessanger.API/AMessanger.API.csproj @@ -0,0 +1,18 @@ + + + + net10.0 + enable + enable + + + + + + + + + + + + diff --git a/AMessanger.API/AMessanger.API.http b/AMessanger.API/AMessanger.API.http new file mode 100644 index 0000000..2db6550 --- /dev/null +++ b/AMessanger.API/AMessanger.API.http @@ -0,0 +1,6 @@ +@AMessanger.API_HostAddress = http://localhost:5004 + +GET {{AMessanger.API_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/AMessanger.API/Controllers/WeatherForecastController.cs b/AMessanger.API/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..f4a9800 --- /dev/null +++ b/AMessanger.API/Controllers/WeatherForecastController.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Mvc; +using AMessanger.Core.Models; + +namespace AMessanger.API.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 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(); + } +} diff --git a/AMessanger.API/Program.cs b/AMessanger.API/Program.cs new file mode 100644 index 0000000..04a7f7d --- /dev/null +++ b/AMessanger.API/Program.cs @@ -0,0 +1,33 @@ +using AMessanger.Core.Hubs; + +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(); + +builder.Services.AddSwaggerGen(); + +builder.Services.AddSignalR(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.MapOpenApi(); +} + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.UseSwagger().UseSwaggerUI(); + +app.MapHub("/hubs/chat"); + +app.Run(); diff --git a/AMessanger.API/Properties/launchSettings.json b/AMessanger.API/Properties/launchSettings.json new file mode 100644 index 0000000..3569348 --- /dev/null +++ b/AMessanger.API/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://localhost:5004", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:7201;http://localhost:5004", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/AMessanger.API/appsettings.json b/AMessanger.API/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/AMessanger.API/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/AMessanger.Core/AMessanger.Core.csproj b/AMessanger.Core/AMessanger.Core.csproj new file mode 100644 index 0000000..2bfe265 --- /dev/null +++ b/AMessanger.Core/AMessanger.Core.csproj @@ -0,0 +1,13 @@ + + + + net10.0 + enable + enable + + + + + + + diff --git a/AMessanger.Core/Hubs/ChatHub.cs b/AMessanger.Core/Hubs/ChatHub.cs new file mode 100644 index 0000000..b562248 --- /dev/null +++ b/AMessanger.Core/Hubs/ChatHub.cs @@ -0,0 +1,13 @@ +using Microsoft.AspNetCore.SignalR; +using Microsoft.Extensions.Logging; + +namespace AMessanger.Core.Hubs; + +public class ChatHub(ILogger logger) : Hub +{ + public async Task SendMessage(string user, string message) + { + logger.LogInformation($"{user}: {message}"); + await Clients.All.SendAsync("ReceiveMessage", user, message); + } +} \ No newline at end of file diff --git a/AMessanger.Core/Models/WeatherForecast.cs b/AMessanger.Core/Models/WeatherForecast.cs new file mode 100644 index 0000000..51a1fae --- /dev/null +++ b/AMessanger.Core/Models/WeatherForecast.cs @@ -0,0 +1,12 @@ +namespace AMessanger.Core.Models; + +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; } +} diff --git a/AMessanger.slnx b/AMessanger.slnx new file mode 100644 index 0000000..04bf814 --- /dev/null +++ b/AMessanger.slnx @@ -0,0 +1,4 @@ + + + + diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 0000000..7720b1b --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,10 @@ + + + true + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..4bd88b3 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# AMessanger Server