Separated laravel app to its own folder (#540)
This commit is contained in:
56
api/app/Providers/AppServiceProvider.php
Normal file
56
api/app/Providers/AppServiceProvider.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Billing\Subscription;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Laravel\Cashier\Cashier;
|
||||
use Laravel\Dusk\DuskServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
if (config('filesystems.default') === 'local') {
|
||||
Storage::disk('local')->buildTemporaryUrlsUsing(function ($path, $expiration, $options) {
|
||||
return URL::temporarySignedRoute(
|
||||
'local.temp',
|
||||
$expiration,
|
||||
array_merge($options, ['path' => $path])
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
JsonResource::withoutWrapping();
|
||||
Cashier::calculateTaxes();
|
||||
Cashier::useSubscriptionModel(Subscription::class);
|
||||
|
||||
if ($this->app->runningUnitTests()) {
|
||||
Schema::defaultStringLength(191);
|
||||
}
|
||||
|
||||
Validator::includeUnvalidatedArrayKeys();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
if ($this->app->environment('local', 'testing') && class_exists(DuskServiceProvider::class)) {
|
||||
$this->app->register(DuskServiceProvider::class);
|
||||
}
|
||||
}
|
||||
}
|
||||
46
api/app/Providers/AuthServiceProvider.php
Normal file
46
api/app/Providers/AuthServiceProvider.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Forms\Form;
|
||||
use App\Models\Integration\FormZapierWebhook;
|
||||
use App\Models\OAuthProvider;
|
||||
use App\Models\Template;
|
||||
use App\Models\Workspace;
|
||||
use App\Policies\FormPolicy;
|
||||
use App\Policies\Integration\FormZapierWebhookPolicy;
|
||||
use App\Policies\OAuthProviderPolicy;
|
||||
use App\Policies\PersonalAccessTokenPolicy;
|
||||
use App\Policies\TemplatePolicy;
|
||||
use App\Policies\WorkspacePolicy;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
use Laravel\Sanctum\PersonalAccessToken;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The policy mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $policies = [
|
||||
Form::class => FormPolicy::class,
|
||||
Workspace::class => WorkspacePolicy::class,
|
||||
FormZapierWebhook::class => FormZapierWebhookPolicy::class,
|
||||
Template::class => TemplatePolicy::class,
|
||||
OAuthProvider::class => OAuthProviderPolicy::class,
|
||||
PersonalAccessToken::class => PersonalAccessTokenPolicy::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
\Illuminate\Support\Facades\Gate::define('viewMailcoach', function ($user = null) {
|
||||
return optional($user)->admin;
|
||||
});
|
||||
}
|
||||
}
|
||||
21
api/app/Providers/BroadcastServiceProvider.php
Normal file
21
api/app/Providers/BroadcastServiceProvider.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Broadcast::routes();
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
||||
61
api/app/Providers/EventServiceProvider.php
Normal file
61
api/app/Providers/EventServiceProvider.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Events\Billing\SubscriptionCreated;
|
||||
use App\Events\Billing\SubscriptionUpdated;
|
||||
use App\Events\Forms\FormSubmitted;
|
||||
use App\Events\Models\FormCreated;
|
||||
use App\Events\Models\FormIntegrationCreated;
|
||||
use App\Events\Models\FormIntegrationsEventCreated;
|
||||
use App\Listeners\Billing\HandleSubscriptionCreated;
|
||||
use App\Listeners\Billing\RemoveWorkspaceGuestsIfNeeded;
|
||||
use App\Listeners\Forms\FormCreationConfirmation;
|
||||
use App\Listeners\Forms\FormIntegrationCreatedHandler;
|
||||
use App\Listeners\Forms\FormIntegrationsEventListener;
|
||||
use App\Listeners\Forms\NotifyFormSubmission;
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event listener mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $listen = [
|
||||
Registered::class => [
|
||||
SendEmailVerificationNotification::class,
|
||||
],
|
||||
FormCreated::class => [
|
||||
FormCreationConfirmation::class,
|
||||
],
|
||||
FormSubmitted::class => [
|
||||
NotifyFormSubmission::class
|
||||
],
|
||||
FormIntegrationCreated::class => [
|
||||
FormIntegrationCreatedHandler::class,
|
||||
],
|
||||
FormIntegrationsEventCreated::class => [
|
||||
FormIntegrationsEventListener::class,
|
||||
],
|
||||
SubscriptionCreated::class => [
|
||||
HandleSubscriptionCreated::class,
|
||||
],
|
||||
SubscriptionUpdated::class => [
|
||||
RemoveWorkspaceGuestsIfNeeded::class
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
42
api/app/Providers/HorizonServiceProvider.php
Normal file
42
api/app/Providers/HorizonServiceProvider.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Laravel\Horizon\Horizon;
|
||||
use Laravel\Horizon\HorizonApplicationServiceProvider;
|
||||
|
||||
class HorizonServiceProvider extends HorizonApplicationServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
// Horizon::routeSmsNotificationsTo('15556667777');
|
||||
// Horizon::routeMailNotificationsTo('example@example.com');
|
||||
// Horizon::routeSlackNotificationsTo('slack-webhook-url', '#channel');
|
||||
|
||||
// Horizon::night();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the Horizon gate.
|
||||
*
|
||||
* This gate determines who can access Horizon in non-local environments.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function gate()
|
||||
{
|
||||
Gate::define('viewHorizon', function ($user) {
|
||||
return in_array($user->email, [
|
||||
'julien@notionforms.io',
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
19
api/app/Providers/PurifySetupProvider.php
Normal file
19
api/app/Providers/PurifySetupProvider.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Service\HtmlPurifier\HTMLPurifier_URIScheme_notion;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class PurifySetupProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
\HTMLPurifier_URISchemeRegistry::instance()->register('notion', new HTMLPurifier_URIScheme_notion());
|
||||
}
|
||||
}
|
||||
59
api/app/Providers/RouteServiceProvider.php
Normal file
59
api/app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The path to the "home" route for your application.
|
||||
*
|
||||
* This is used by Laravel authentication to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/home';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->configureRateLimiting();
|
||||
$this->registerGlobalRouteParamConstraints();
|
||||
|
||||
$this->routes(function () {
|
||||
Route::middleware('api')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/api.php'));
|
||||
|
||||
Route::middleware('api-external')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/api-external.php'));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the rate limiters for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function configureRateLimiting()
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
}
|
||||
|
||||
protected function registerGlobalRouteParamConstraints()
|
||||
{
|
||||
Route::pattern('workspaceId', '[0-9]+');
|
||||
}
|
||||
}
|
||||
43
api/app/Providers/VaporUiServiceProvider.php
Normal file
43
api/app/Providers/VaporUiServiceProvider.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class VaporUiServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->gate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the Vapor UI gate.
|
||||
*
|
||||
* This gate determines who can access Vapor UI in non-local environments.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function gate()
|
||||
{
|
||||
Gate::define('viewVaporUI', function ($user) {
|
||||
return $user->admin;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user