trypost/routes/api.php
Paulo Castellano 039ed02b42 feat: rate limiting, cleanup duplicates, ApiKey app tests, bootstrap hardening
- Add API rate limiting (60/min per workspace) in AppServiceProvider
- Add throttle:api middleware to all API routes
- Add rate limit exception rendering for JSON responses
- Add middleware priority list (AuthenticateApiToken before ThrottleRequests)
- Add ApiKeyControllerTest (6 tests for App dashboard CRUD)
- Remove duplicate test files (Controllers/ dir duplicates)
- Remove old controllers and routes/settings.php
- Add routes/mcp.php placeholder
- Add API Keys nav item to settings layout
- Fix LazilyRefreshDatabase conflict in API tests
- 698 tests passing
2026-03-29 20:14:23 -03:00

45 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
use App\Http\Controllers\Api\ApiKeyController;
use App\Http\Controllers\Api\HashtagController;
use App\Http\Controllers\Api\LabelController;
use App\Http\Controllers\Api\PostController;
use App\Http\Controllers\Api\WorkspaceController;
use Illuminate\Support\Facades\Route;
Route::group(
[
'domain' => 'api.'.parse_url(config('app.url'), PHP_URL_HOST),
'middleware' => ['api.auth', 'throttle:api'],
],
function () {
// Posts
Route::get('/posts', [PostController::class, 'index'])->name('api.posts.index');
Route::post('/posts', [PostController::class, 'store'])->name('api.posts.store');
Route::get('/posts/{post}', [PostController::class, 'show'])->name('api.posts.show');
Route::put('/posts/{post}', [PostController::class, 'update'])->name('api.posts.update');
Route::delete('/posts/{post}', [PostController::class, 'destroy'])->name('api.posts.destroy');
// Workspace
Route::get('/workspace', [WorkspaceController::class, 'show'])->name('api.workspace.show');
// Hashtags
Route::get('/hashtags', [HashtagController::class, 'index'])->name('api.hashtags.index');
Route::post('/hashtags', [HashtagController::class, 'store'])->name('api.hashtags.store');
Route::put('/hashtags/{hashtag}', [HashtagController::class, 'update'])->name('api.hashtags.update');
Route::delete('/hashtags/{hashtag}', [HashtagController::class, 'destroy'])->name('api.hashtags.destroy');
// Labels
Route::get('/labels', [LabelController::class, 'index'])->name('api.labels.index');
Route::post('/labels', [LabelController::class, 'store'])->name('api.labels.store');
Route::put('/labels/{label}', [LabelController::class, 'update'])->name('api.labels.update');
Route::delete('/labels/{label}', [LabelController::class, 'destroy'])->name('api.labels.destroy');
// API Keys
Route::get('/api-keys', [ApiKeyController::class, 'index'])->name('api.api-keys.index');
Route::post('/api-keys', [ApiKeyController::class, 'store'])->name('api.api-keys.store');
Route::delete('/api-keys/{apiToken}', [ApiKeyController::class, 'destroy'])->name('api.api-keys.destroy');
}
);