Refactor classes to use constructor injection for dependencies

- Updated IrcBroadcaster to use constructor injection for IrcGatewayService.
- Refactored JwtTokenService to initialize configuration values in the constructor.
- Modified AuthController to use constructor injection for EchoHubDbContext and JwtTokenService.
- Refactored ChannelsController to utilize constructor injection for dependencies.
- Updated FilesController to use constructor injection for FileStorageService.
- Refactored ServerController to initialize EchoHubDbContext and IConfiguration via constructor.
- Modified UsersController to use constructor injection for EchoHubDbContext and ImageToAsciiService.
- Updated EchoHubDbContext to use constructor for DbContextOptions.
- Refactored ChatHub to use constructor injection for IChatService and ILogger.
- Modified ChatService to utilize constructor injection for dependencies.
- Refactored ServerDirectoryService to use constructor injection for IConfiguration, PresenceTracker, and ILogger.
This commit is contained in:
HueByte
2026-02-19 14:04:19 +01:00
parent 0422066851
commit 13297fd017
11 changed files with 248 additions and 156 deletions
@@ -10,15 +10,21 @@ namespace EchoHub.Server.Controllers;
[Route("api/files")]
[Authorize]
[EnableRateLimiting("general")]
public class FilesController(FileStorageService fileStorage) : ControllerBase
public class FilesController : ControllerBase
{
private readonly FileStorageService _fileStorage;
public FilesController(FileStorageService fileStorage)
{
_fileStorage = fileStorage;
}
[HttpGet("{fileId}")]
public IActionResult GetFile(string fileId)
{
if (!Guid.TryParse(fileId, out _))
return BadRequest(new ErrorResponse("Invalid file identifier."));
var filePath = fileStorage.GetFilePath(fileId);
var filePath = _fileStorage.GetFilePath(fileId);
if (filePath is null)
return NotFound(new ErrorResponse("File not found."));