<?php

use Illuminate\Support\Facades\Route;
use Modules\Common\Http\Controllers\ModuleController;
use Modules\Common\Http\Controllers\OptionController;
use Modules\Common\Http\Controllers\Qiniu\CallbackController;
use Modules\Common\Http\Controllers\Qiniu\ImageUploadController;
use Modules\Common\Http\Controllers\UploadController;
use Modules\Permissions\Middlewares\PermissionGate;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::get('options/{name}', [OptionController::class, 'index']);

Route::controller(UploadController::class)->group(function (){
    Route::post('upload/file',  'file');
    Route::post('upload/image', 'image');
    // get oss signature
    Route::get('upload/oss', 'oss');
});

Route::get('modules/listApp', [ModuleController::class, 'listApp']);

Route::prefix('qiniu')->group(function() {
    Route::get('upload/token', [CallbackController::class, 'uploadToken']);
    Route::get('downloadUrl', [CallbackController::class, 'downloadUrl']);
    Route::post('upload/callback', [CallbackController::class, 'callback'])->withoutMiddleware(config('catch.route.middlewares'));
    Route::post('upload/image', [ImageUploadController::class, 'uploadImage'])->withoutMiddleware([PermissionGate::class]);
});


