mirror of
https://github.com/ryzij/AMessanger-Server.git
synced 2026-09-18 19:25:38 +00:00
Compare commits
4 Commits
f158efc762
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 6a3738d20a | |||
| d141969e45 | |||
| 0bea967bcf | |||
| 71b377f214 |
@@ -12,6 +12,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../AMessanger.Application/AMessanger.Application.csproj" />
|
||||
<ProjectReference Include="../AMessanger.Core/AMessanger.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using AMessanger.Core.Hubs;
|
||||
using AMessanger.Application.Hubs;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../AMessanger.Core/AMessanger.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.SignalR" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,14 @@
|
||||
using AMessanger.Core.Models;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AMessanger.Application.Hubs;
|
||||
|
||||
public class ChatHub(ILogger<ChatHub> logger) : Hub
|
||||
{
|
||||
public async Task SendMessage(Message message)
|
||||
{
|
||||
logger.LogInformation($"{message.UserName}: {message.Content}");
|
||||
await Clients.All.SendAsync("ReceiveMessage", message);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.SignalR" />
|
||||
<PackageReference Include="Newtonsoft.Json" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AMessanger.Core.Hubs;
|
||||
|
||||
public class ChatHub(ILogger<ChatHub> logger) : Hub
|
||||
{
|
||||
public async Task SendMessage(string user, string message)
|
||||
{
|
||||
logger.LogInformation($"{user}: {message}");
|
||||
await Clients.All.SendAsync("ReceiveMessage", user, message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace AMessanger.Core.Models
|
||||
{
|
||||
public class Message(string userName, string content)
|
||||
{
|
||||
public string UserName { get; set; } = userName;
|
||||
public string Content { get; set; } = content;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,9 @@
|
||||
<Solution>
|
||||
<Project Path="AMessanger.API/AMessanger.API.csproj" />
|
||||
<Project Path="AMessanger.Application/AMessanger.Application.csproj" />
|
||||
<Project Path="AMessanger.Core/AMessanger.Core.csproj" />
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.SignalR" />
|
||||
</ItemGroup>
|
||||
</Solution>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<ItemGroup>
|
||||
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.11" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.SignalR" Version="1.2.12" />
|
||||
<PackageVersion Include="Newtonsoft.Json" Version="13.0.4" />
|
||||
<PackageVersion Include="Swashbuckle.AspNetCore" Version="10.2.3" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,28 @@
|
||||
services:
|
||||
api:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: AMessanger.API/Dockerfile
|
||||
ports:
|
||||
- "5000:8080"
|
||||
depends_on:
|
||||
- db
|
||||
environment:
|
||||
ConnectionStrings__DefaultConnection: Host=db;Database=${POSTGRES_DB};Username=${POSTGRES_USER};Password=${POSTGRES_PASSWORD}
|
||||
Jwt__Key: ${JWT_KEY}
|
||||
Jwt__ExpiresMinutes: "${JWT_EXPIRES_MINUTES}"
|
||||
Jwt__Issuer: "${JWT_ISSUER}"
|
||||
Jwt__Audience: "#{JWT_AUDIENCE}"
|
||||
|
||||
db:
|
||||
image: postgres:17
|
||||
restart: always
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
POSTGRES_DB: ${POSTGRES_DB}
|
||||
volumes:
|
||||
- pg_data:/var/lib/postgresql/data
|
||||
|
||||
volumes:
|
||||
pg_data:
|
||||
Reference in New Issue
Block a user