try again

This commit is contained in:
gilesb 2024-03-09 15:32:32 +00:00
parent 1f3f1d7299
commit c7cd0468f1
2 changed files with 184 additions and 186 deletions

View File

@ -30,7 +30,7 @@ class RouteServiceProvider extends ServiceProvider
$this->registerGlobalRouteParamConstraints();
$this->routes(function () {
Route::middleware('api')
Route::middleware($_ENV['APP_API_PREFIX'] ?? 'api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
});
@ -43,7 +43,7 @@ class RouteServiceProvider extends ServiceProvider
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
RateLimiter::for($_ENV['APP_API_PREFIX'] ?? 'api', function (Request $request) {
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
});
}

View File

@ -34,9 +34,8 @@ use Illuminate\Support\Facades\Storage;
| 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::get('user', [UserController::class, 'current'])->name('user.current');
@ -145,9 +144,9 @@ Route::group(['prefix' => $_ENV['API_PREFIX'] ?? ''], function () {
[\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('register', [RegisterController::class, 'register']);
@ -159,17 +158,17 @@ Route::group(['prefix' => $_ENV['API_PREFIX'] ?? ''], function () {
Route::post('oauth/{driver}', [OAuthController::class, 'redirect']);
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::post('webhook', [\App\Http\Controllers\Webhook\AppSumoController::class, 'handle'])->name('appsumo.webhook');
});
});
/*
/*
* 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::post('{slug}/answer', [PublicFormController::class, 'answer'])->name('answer');
@ -190,41 +189,41 @@ Route::group(['prefix' => $_ENV['API_PREFIX'] ?? ''], function () {
// AI
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');
});
});
/**
/**
* 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('/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
Route::prefix('templates')->group(function () {
// Templates
Route::prefix('templates')->group(function () {
Route::get('/', [TemplateController::class, 'index'])->name('templates.index');
Route::post('/', [TemplateController::class, 'create'])->name('templates.create');
Route::get('/{slug}', [TemplateController::class, 'show'])->name('templates.show');
Route::put('/{id}', [TemplateController::class, 'update'])->name('templates.update');
Route::delete('/{id}', [TemplateController::class, 'destroy'])->name('templates.destroy');
});
});
Route::post(
Route::post(
'/stripe/webhook',
[\App\Http\Controllers\Webhook\StripeController::class, 'handleWebhook']
)->name('cashier.webhook');
)->name('cashier.webhook');
Route::post(
Route::post(
'/vapor/signed-storage-url',
[\App\Http\Controllers\Content\SignedStorageUrlController::class, 'store']
)->middleware([]);
Route::post(
)->middleware([]);
Route::post(
'/upload-file',
[\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()) {
abort(401);
}
@ -232,8 +231,7 @@ Route::group(['prefix' => $_ENV['API_PREFIX'] ?? ''], function () {
$response->header('Content-Type', Storage::mimeType($path));
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);
});