diff --git a/apps/api/app/controllers/api/images_controller.rb b/apps/api/app/controllers/api/images_controller.rb index 1fb26d0..05725c6 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(ImageShowInputDTO.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 e4edee1..1059098 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(FileShowInputDTO.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 8ac7327..40432a9 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 = UpdateInputDTO.new( + input = UpdateInputDto.new( platform: params[:platform], name: params[:name], version: params[:version] diff --git a/apps/api/app/dtos/file_result_dto.rb b/apps/api/app/dtos/file_result_dto.rb index 4862e68..1809e60 100644 --- a/apps/api/app/dtos/file_result_dto.rb +++ b/apps/api/app/dtos/file_result_dto.rb @@ -1,4 +1,4 @@ -class FileResultDTO +class FileResultDto attr_reader :type, :path, :url def initialize(type:, path: nil, url: nil) diff --git a/apps/api/app/dtos/file_show_input_dto.rb b/apps/api/app/dtos/file_show_input_dto.rb index 1f3e5e0..ac27669 100644 --- a/apps/api/app/dtos/file_show_input_dto.rb +++ b/apps/api/app/dtos/file_show_input_dto.rb @@ -1 +1 @@ -FileShowInputDTO = Struct.new(:path, keyword_init: true) +FileShowInputDto = Struct.new(:path, keyword_init: true) diff --git a/apps/api/app/dtos/image_show_input_dto.rb b/apps/api/app/dtos/image_show_input_dto.rb index 40348ab..df74c61 100644 --- a/apps/api/app/dtos/image_show_input_dto.rb +++ b/apps/api/app/dtos/image_show_input_dto.rb @@ -1 +1 @@ -ImageShowInputDTO = Struct.new(:id, keyword_init: true) +ImageShowInputDto = Struct.new(:id, keyword_init: true) diff --git a/apps/api/app/dtos/update_input_dto.rb b/apps/api/app/dtos/update_input_dto.rb index f32469b..d025174 100644 --- a/apps/api/app/dtos/update_input_dto.rb +++ b/apps/api/app/dtos/update_input_dto.rb @@ -1,4 +1,4 @@ -UpdateInputDTO = 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 67cf57d..57ac62a 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 FileResultDTO.not_found unless File.file?(index_path) - return FileResultDTO.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) - FileResultDTO.file(full_path) + FileResultDto.file(full_path) else - FileResultDTO.not_found + FileResultDto.not_found end end end