allow api prefix

This commit is contained in:
gilesb 2024-03-09 13:39:01 +00:00
parent 30587fb3df
commit b3f59a7513
1 changed files with 169 additions and 167 deletions

View File

@ -34,8 +34,8 @@ use Illuminate\Support\Facades\Storage;
| is assigned the "api" middleware group. Enjoy building your API! | is assigned the "api" middleware group. Enjoy building your API!
| |
*/ */
Route::group(['prefix' => $_ENV['API_PREFIX'] ?? ''], function () {
Route::group(['middleware' => 'auth:api'], function () { Route::group(['middleware' => 'auth:api'], function () {
Route::post('logout', [LoginController::class, 'logout']); Route::post('logout', [LoginController::class, 'logout']);
Route::get('user', [UserController::class, 'current'])->name('user.current'); Route::get('user', [UserController::class, 'current'])->name('user.current');
@ -144,9 +144,9 @@ Route::group(['middleware' => 'auth:api'], function () {
[\App\Http\Controllers\Admin\ImpersonationController::class, 'impersonate'] [\App\Http\Controllers\Admin\ImpersonationController::class, 'impersonate']
); );
}); });
}); });
Route::group(['middleware' => 'guest:api'], function () { Route::group(['middleware' => 'guest:api'], function () {
Route::post('login', [LoginController::class, 'login']); Route::post('login', [LoginController::class, 'login']);
Route::post('register', [RegisterController::class, 'register']); Route::post('register', [RegisterController::class, 'register']);
@ -158,17 +158,17 @@ Route::group(['middleware' => 'guest:api'], function () {
Route::post('oauth/{driver}', [OAuthController::class, 'redirect']); Route::post('oauth/{driver}', [OAuthController::class, 'redirect']);
Route::get('oauth/{driver}/callback', [OAuthController::class, 'handleCallback'])->name('oauth.callback'); Route::get('oauth/{driver}/callback', [OAuthController::class, 'handleCallback'])->name('oauth.callback');
}); });
Route::group(['prefix' => 'appsumo'], function () { Route::group(['prefix' => 'appsumo'], function () {
Route::get('oauth/callback', [\App\Http\Controllers\Auth\AppSumoAuthController::class, 'handleCallback'])->name('appsumo.callback'); Route::get('oauth/callback', [\App\Http\Controllers\Auth\AppSumoAuthController::class, 'handleCallback'])->name('appsumo.callback');
Route::post('webhook', [\App\Http\Controllers\Webhook\AppSumoController::class, 'handle'])->name('appsumo.webhook'); Route::post('webhook', [\App\Http\Controllers\Webhook\AppSumoController::class, 'handle'])->name('appsumo.webhook');
}); });
/* /*
* Public Forms related routes * Public Forms related routes
*/ */
Route::prefix('forms')->name('forms.')->group(function () { Route::prefix('forms')->name('forms.')->group(function () {
Route::middleware('protected-form')->group(function () { Route::middleware('protected-form')->group(function () {
Route::post('{slug}/answer', [PublicFormController::class, 'answer'])->name('answer'); Route::post('{slug}/answer', [PublicFormController::class, 'answer'])->name('answer');
@ -189,41 +189,41 @@ Route::prefix('forms')->name('forms.')->group(function () {
// AI // AI
Route::post('ai/generate', [\App\Http\Controllers\Forms\AiFormController::class, 'generateForm'])->name('ai.generate'); Route::post('ai/generate', [\App\Http\Controllers\Forms\AiFormController::class, 'generateForm'])->name('ai.generate');
Route::get('ai/{aiFormCompletion}', [\App\Http\Controllers\Forms\AiFormController::class, 'show'])->name('ai.show'); Route::get('ai/{aiFormCompletion}', [\App\Http\Controllers\Forms\AiFormController::class, 'show'])->name('ai.show');
}); });
/** /**
* Other public routes * Other public routes
*/ */
Route::prefix('content')->name('content.')->group(function () { Route::prefix('content')->name('content.')->group(function () {
Route::get('changelog/entries', [\App\Http\Controllers\Content\ChangelogController::class, 'index'])->name('changelog.entries'); Route::get('changelog/entries', [\App\Http\Controllers\Content\ChangelogController::class, 'index'])->name('changelog.entries');
}); });
Route::get('/sitemap-urls', [\App\Http\Controllers\SitemapController::class, 'index'])->name('sitemap.index'); Route::get('/sitemap-urls', [\App\Http\Controllers\SitemapController::class, 'index'])->name('sitemap.index');
// Templates // Templates
Route::prefix('templates')->group(function () { Route::prefix('templates')->group(function () {
Route::get('/', [TemplateController::class, 'index'])->name('templates.index'); Route::get('/', [TemplateController::class, 'index'])->name('templates.index');
Route::post('/', [TemplateController::class, 'create'])->name('templates.create'); Route::post('/', [TemplateController::class, 'create'])->name('templates.create');
Route::get('/{slug}', [TemplateController::class, 'show'])->name('templates.show'); Route::get('/{slug}', [TemplateController::class, 'show'])->name('templates.show');
Route::put('/{id}', [TemplateController::class, 'update'])->name('templates.update'); Route::put('/{id}', [TemplateController::class, 'update'])->name('templates.update');
Route::delete('/{id}', [TemplateController::class, 'destroy'])->name('templates.destroy'); Route::delete('/{id}', [TemplateController::class, 'destroy'])->name('templates.destroy');
}); });
Route::post( Route::post(
'/stripe/webhook', '/stripe/webhook',
[\App\Http\Controllers\Webhook\StripeController::class, 'handleWebhook'] [\App\Http\Controllers\Webhook\StripeController::class, 'handleWebhook']
)->name('cashier.webhook'); )->name('cashier.webhook');
Route::post( Route::post(
'/vapor/signed-storage-url', '/vapor/signed-storage-url',
[\App\Http\Controllers\Content\SignedStorageUrlController::class, 'store'] [\App\Http\Controllers\Content\SignedStorageUrlController::class, 'store']
)->middleware([]); )->middleware([]);
Route::post( Route::post(
'/upload-file', '/upload-file',
[\App\Http\Controllers\Content\FileUploadController::class, 'upload'] [\App\Http\Controllers\Content\FileUploadController::class, 'upload']
)->middleware([]); )->middleware([]);
Route::get('local/temp/{path}', function (Request $request, string $path) { Route::get('local/temp/{path}', function (Request $request, string $path) {
if (! $request->hasValidSignature()) { if (! $request->hasValidSignature()) {
abort(401); abort(401);
} }
@ -231,7 +231,9 @@ Route::get('local/temp/{path}', function (Request $request, string $path) {
$response->header('Content-Type', Storage::mimeType($path)); $response->header('Content-Type', Storage::mimeType($path));
return $response; return $response;
})->where('path', '(.*)')->name('local.temp'); })->where('path', '(.*)')->name('local.temp');
Route::get('caddy/ask-certificate/{secret?}', [\App\Http\Controllers\CaddyController::class, 'ask']) Route::get('caddy/ask-certificate/{secret?}', [\App\Http\Controllers\CaddyController::class, 'ask'])
->name('caddy.ask')->middleware(\App\Http\Middleware\CaddyRequestMiddleware::class); ->name('caddy.ask')->middleware(\App\Http\Middleware\CaddyRequestMiddleware::class);
}
)