diff --git a/apps/api/app/controllers/api/images_controller.rb b/apps/api/app/controllers/api/images_controller.rb index 3a1e71a..1fb26d0 100644 --- a/apps/api/app/controllers/api/images_controller.rb +++ b/apps/api/app/controllers/api/images_controller.rb @@ -1,6 +1,6 @@ class Api::ImagesController < ApplicationController def show - image = ImageService.new.show(ImageShowInput.new(id: params[:id])) + image = ImageService.new.show(ImageShowInputDTO.new(id: params[:id])) send_file image.file_path, type: image.content_type, disposition: "inline" rescue ActiveRecord::RecordNotFound render plain: "Not Found", status: :not_found diff --git a/apps/api/app/controllers/files_controller.rb b/apps/api/app/controllers/files_controller.rb index e173f0f..e4edee1 100644 --- a/apps/api/app/controllers/files_controller.rb +++ b/apps/api/app/controllers/files_controller.rb @@ -2,7 +2,7 @@ class FilesController < ApplicationController skip_forgery_protection def show - result = FileService.new.show(FileShowInput.new(path: params[:path])) + result = FileService.new.show(FileShowInputDTO.new(path: params[:path])) case result.type when :redirect then redirect_to result.url, status: :moved_permanently when :file diff --git a/apps/api/app/controllers/update_controller.rb b/apps/api/app/controllers/update_controller.rb index 6b50dd4..8ac7327 100644 --- a/apps/api/app/controllers/update_controller.rb +++ b/apps/api/app/controllers/update_controller.rb @@ -3,7 +3,7 @@ class UpdateController < ApiController return render plain: "Unauthorized", status: :unauthorized unless authorized? return render plain: "Version not provided", status: :bad_request if params[:version].blank? - input = UpdateInput.new( + input = UpdateInputDTO.new( platform: params[:platform], name: params[:name], version: params[:version] diff --git a/apps/api/app/dtos/file_result.rb b/apps/api/app/dtos/file_result.rb index f221f64..4862e68 100644 --- a/apps/api/app/dtos/file_result.rb +++ b/apps/api/app/dtos/file_result.rb @@ -1,4 +1,4 @@ -class FileResult +class FileResultDTO attr_reader :type, :path, :url def initialize(type:, path: nil, url: nil) diff --git a/apps/api/app/dtos/file_show_input.rb b/apps/api/app/dtos/file_show_input.rb index ce15e6d..1f3e5e0 100644 --- a/apps/api/app/dtos/file_show_input.rb +++ b/apps/api/app/dtos/file_show_input.rb @@ -1 +1 @@ -FileShowInput = Struct.new(:path, keyword_init: true) +FileShowInputDTO = Struct.new(:path, keyword_init: true) diff --git a/apps/api/app/dtos/image_show_input.rb b/apps/api/app/dtos/image_show_input.rb index d6ae0dc..40348ab 100644 --- a/apps/api/app/dtos/image_show_input.rb +++ b/apps/api/app/dtos/image_show_input.rb @@ -1 +1 @@ -ImageShowInput = Struct.new(:id, keyword_init: true) +ImageShowInputDTO = Struct.new(:id, keyword_init: true) diff --git a/apps/api/app/dtos/update_input.rb b/apps/api/app/dtos/update_input.rb index 5af3beb..f32469b 100644 --- a/apps/api/app/dtos/update_input.rb +++ b/apps/api/app/dtos/update_input.rb @@ -1,4 +1,4 @@ -UpdateInput = Struct.new(:platform, :name, :version, keyword_init: true) do +UpdateInputDTO = Struct.new(:platform, :name, :version, keyword_init: true) do def initialize(platform:, name:, version: nil) super end diff --git a/apps/api/app/services/file_service.rb b/apps/api/app/services/file_service.rb index 9144a11..67cf57d 100644 --- a/apps/api/app/services/file_service.rb +++ b/apps/api/app/services/file_service.rb @@ -6,14 +6,14 @@ class FileService if File.directory?(full_path) index_path = full_path.join("index.html") - return FileResult.not_found unless File.file?(index_path) - return FileResult.redirect("/file/#{input.path.to_s.chomp("/")}/index.html") + return FileResultDTO.not_found unless File.file?(index_path) + return FileResultDTO.redirect("/file/#{input.path.to_s.chomp("/")}/index.html") end if File.file?(full_path) - FileResult.file(full_path) + FileResultDTO.file(full_path) else - FileResult.not_found + FileResultDTO.not_found end end end