Initial commit / First Release

This commit is contained in:
Fabián Gonzalo Artur de la Villarmois
2025-12-26 16:51:23 +13:00
parent 2e8f5ce028
commit 2579f561c3
73 changed files with 14521 additions and 0 deletions
@@ -0,0 +1,37 @@
<?php
namespace App\Http\Controllers\Tinfoil;
use App\Enums\NintendoFileExtension;
use App\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Storage;
class IndexController extends Controller
{
/**
* Handle the incoming request from Tinfoil client.
* Returns a JSON list of available Nintendo Switch installation files.
*/
public function __invoke(): JsonResponse
{
return response()->json([
'files' => $this->getInstallableFiles()->values(),
'success' => config('app.name')
]);
}
/**
* Get all Nintendo Switch installable files from storage.
*/
private function getInstallableFiles(): Collection
{
return collect(Storage::allFiles())
->filter(fn ($path) => NintendoFileExtension::isSupported($path))
->map(fn ($path) => [
'url' => url($path),
'size' => Storage::size($path)
]);
}
}