Initial commit: ThinkPHP refactor (tp)
Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use think\facade\Route;
|
||||
use app\api\controller\Index;
|
||||
use app\api\controller\User;
|
||||
use app\api\controller\V1Auth;
|
||||
|
||||
/**
|
||||
* API 路由配置
|
||||
*/
|
||||
|
||||
// ==================== v1 版本接口 ====================
|
||||
|
||||
// 健康检查 (公开)
|
||||
Route::get('api/v1/health', [Index::class, 'health']);
|
||||
|
||||
// 认证接口 (公开)
|
||||
Route::post('api/v1/auth/login', [V1Auth::class, 'login']);
|
||||
Route::post('api/v1/auth/register', [V1Auth::class, 'register']);
|
||||
Route::post('api/v1/auth/refresh', [V1Auth::class, 'refresh']);
|
||||
|
||||
// 认证接口 (需登录)
|
||||
Route::group('api/v1/auth', function () {
|
||||
Route::get('me', [V1Auth::class, 'me']);
|
||||
Route::post('logout', [V1Auth::class, 'logout']);
|
||||
Route::post('password', [V1Auth::class, 'password']);
|
||||
})->middleware(\app\api\middleware\Auth::class);
|
||||
|
||||
// ==================== 兼容旧版路由 ====================
|
||||
|
||||
Route::get('api/index', [Index::class, 'index']);
|
||||
Route::get('api/health', [Index::class, 'health']);
|
||||
Route::post('api/user/login', [V1Auth::class, 'login']);
|
||||
Route::post('api/user/register', [V1Auth::class, 'register']);
|
||||
Route::get('api/user/info', [V1Auth::class, 'me'])->middleware(\app\api\middleware\Auth::class);
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
use think\facade\Route;
|
||||
|
||||
Route::get('think', function () {
|
||||
return 'hello,ThinkPHP8!';
|
||||
});
|
||||
|
||||
Route::get('hello/:name', 'index/hello');
|
||||
Reference in New Issue
Block a user