Skip to content

Commit

Permalink
Added api route for forge updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucraft committed Feb 7, 2024
1 parent b23301f commit b368f09
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/Api/Controllers/ForgeUpdateJsonController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Api\Controllers;

use App\Api\Response\Response;

class ForgeUpdateJsonController
{

public function updateJson(string $mod): array
{
$modrinthLink = "https://api.modrinth.com/updates/$mod/forge_updates.json";
$data = json_decode(file_get_contents($modrinthLink), true);

$promos = data_get($data, 'promos');
foreach ($promos as $key => $value) {
$promos[$key] = explode('+', $value)[0];
}

$data['promos'] = $promos;
return $data;
}

}
1 change: 1 addition & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
Route::get('/player/{uuid}', 'MinecraftPlayerController@getData');
Route::get('/legacy/data', 'MinecraftPlayerController@getLegacyData');
Route::post('/mod-update-post', 'ModUpdatePostController@store');
Route::get('/forge_updates/{mod}', 'ForgeUpdateJsonController@updateJson');

0 comments on commit b368f09

Please sign in to comment.