Commit 2d88155c authored by Jacob Priddy's avatar Jacob Priddy 👌

service provider optimizations

parent 39b392cc
......@@ -34,6 +34,19 @@ class AuthController extends ApiController
$this->cookieJar = $cookieJar;
}
/**
* Welcome
*
* This endpoint requires no auth and is the welcome page for any API user.
*
* @return \Illuminate\Http\JsonResponse
*/
public function welcome(): JsonResponse
{
dd(microtime(true) - LARAVEL_START);
return new JsonResponse(['welcome' => 'Welcome to the elock API.']);
}
/**
* Login request to application
*
......
......@@ -3,172 +3,9 @@
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Source\Authorization\AuthorizerServiceProvider;
use Source\Gateways\Saml\SamlRepositoryServiceProvider;
use Source\Gateways\Doors\DoorsRepositoryServiceProvider;
use Source\Gateways\Users\UsersRepositoryServiceProvider;
use Source\UseCases\Door\Commands\CommandServiceProvider;
use Source\Gateways\Groups\GroupsRepositoryServiceProvider;
use Source\Gateways\Tokens\TokensRepositoryServiceProvider;
use Source\Gateways\Entries\EntriesRepositoryServiceProvider;
use Source\UseCases\Door\Access\AccessUseCaseServiceProvider;
use Source\Gateways\Attempts\AttemptsRepositoryServiceProvider;
use Source\Gateways\DoorUser\DoorUserRepositoryServiceProvider;
use Source\UseCases\Doors\GetDoor\GetDoorUseCaseServiceProvider;
use Source\UseCases\Users\GetUser\GetUserUseCaseServiceProvider;
use Source\Gateways\DoorGroup\DoorGroupRepositoryServiceProvider;
use Source\Gateways\GroupUser\GroupUserRepositoryServiceProvider;
use Source\Gateways\Overrides\OverridesRepositoryServiceProvider;
use Source\Gateways\Schedules\SchedulesRepositoryServiceProvider;
use Source\UseCases\Doors\GetDoors\GetDoorsUseCaseServiceProvider;
use Source\Gateways\Filesystem\FilesystemRepositoryServiceProvider;
use Source\UseCases\Groups\GetGroup\GetGroupUseCaseServiceProvider;
use Source\UseCases\Tokens\GetToken\GetTokenUseCaseServiceProvider;
use Source\UseCases\Groups\GetGroups\GetGroupsUseCaseServiceProvider;
use Source\UseCases\Tokens\GetTokens\GetTokensUseCaseServiceProvider;
use Source\UseCases\Users\GetUsers\GetAllUsersUseCaseServiceProvider;
use Source\UseCases\Doors\CreateDoor\CreateDoorUseCaseServiceProvider;
use Source\UseCases\Doors\DeleteDoor\DeleteDoorUseCaseServiceProvider;
use Source\UseCases\Doors\UpdateDoor\UpdateDoorUseCaseServiceProvider;
use Source\UseCases\Users\CreateUser\CreateUserUseCaseServiceProvider;
use Source\UseCases\Users\DeleteUser\DeleteUserUseCaseServiceProvider;
use Source\UseCases\Users\UpdateUser\UpdateUserUseCaseServiceProvider;
use Source\Gateways\DoorSchedule\DoorScheduleRepositoryServiceProvider;
use Source\UseCases\Entries\GetEntries\GetEntriesUseCaseServiceProvider;
use Source\Gateways\RecurrenceSet\RecurrenceSetRepositoryServiceProvider;
use Source\UseCases\Door\UpdateBinary\UpdateBinaryUseCaseServiceProvider;
use Source\UseCases\Groups\CreateGroup\CreateGroupUseCaseServiceProvider;
use Source\UseCases\Groups\DeleteGroup\DeleteGroupUseCaseServiceProvider;
use Source\UseCases\Groups\UpdateGroup\UpdateGroupUseCaseServiceProvider;
use Source\UseCases\Tokens\CreateToken\CreateTokenUseCaseServiceProvider;
use Source\UseCases\Tokens\ExpireToken\ExpireTokenUseCaseServiceProvider;
use Source\UseCases\Tokens\UpdateToken\UpdateTokenUseCaseServiceProvider;
use Source\UseCases\Attempts\GetAttempts\GetAttemptsUseCaseServiceProvider;
use Source\UseCases\Overrides\OverrideGet\OverrideGetUseCaseServiceProvider;
use Source\UseCases\Schedules\ScheduleGet\ScheduleGetUseCaseServiceProvider;
use Source\UseCases\Door\StatusResponse\StatusResponseUseCaseServiceProvider;
use Source\UseCases\Overrides\OverridesGet\OverridesGetUseCaseServiceProvider;
use Source\UseCases\Schedules\SchedulesGet\SchedulesGetUseCaseServiceProvider;
use Source\UseCases\DoorGroup\GetDoorGroups\GetDoorGroupsUseCaseServiceProvider;
use Source\UseCases\DoorGroup\GetGroupDoors\GetGroupDoorsUseCaseServiceProvider;
use Source\UseCases\GroupUser\GetGroupUsers\GetGroupUsersUseCaseServiceProvider;
use Source\UseCases\GroupUser\GetUserGroups\GetUserGroupsUseCaseServiceProvider;
use Source\UseCases\DoorUser\UserDoorAccess\UserDoorAccessUseCaseServiceProvider;
use Source\UseCases\DoorGroup\AddDoorToGroup\AddDoorToGroupUseCaseServiceProvider;
use Source\UseCases\GroupUser\AddUserToGroup\AddUserToGroupUseCaseServiceProvider;
use Source\UseCases\Overrides\OverrideCreate\OverrideCreateUseCaseServiceProvider;
use Source\UseCases\Overrides\OverrideUpdate\OverrideUpdateUseCaseServiceProvider;
use Source\UseCases\Schedules\ScheduleCreate\ScheduleCreateUseCaseServiceProvider;
use Source\UseCases\Schedules\ScheduleUpdate\ScheduleUpdateUseCaseServiceProvider;
use Source\UseCases\Doors\GenerateDoorToken\GenerateDoorTokenUseCaseServiceProvider;
use Source\UseCases\DoorGroup\RemoveDoorFromGroup\RemoveDoorFromGroupUseCaseServiceProvider;
use Source\UseCases\GroupUser\RemoveUserFromGroup\RemoveUserFromGroupUseCaseServiceProvider;
use Source\UseCases\Door\Authenticate\AuthenticateUseCaseServiceProvider as DoorAuthenticateUseCaseServiceProvider;
use Source\UseCases\Users\Authenticate\AuthenticateUseCaseServiceProvider as UserAuthenticateUseCaseServiceProvider;
use Source\UseCases\Token\Authenticate\AuthenticateUseCaseServiceProvider as TokenAuthenticateUseCaseServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* @var string[]
*/
protected array $gatewayProviders = [
AuthorizerServiceProvider::class,
SamlRepositoryServiceProvider::class,
UsersRepositoryServiceProvider::class,
DoorsRepositoryServiceProvider::class,
TokensRepositoryServiceProvider::class,
GroupsRepositoryServiceProvider::class,
EntriesRepositoryServiceProvider::class,
AttemptsRepositoryServiceProvider::class,
DoorUserRepositoryServiceProvider::class,
SchedulesRepositoryServiceProvider::class,
DoorGroupRepositoryServiceProvider::class,
GroupUserRepositoryServiceProvider::class,
OverridesRepositoryServiceProvider::class,
FilesystemRepositoryServiceProvider::class,
DoorScheduleRepositoryServiceProvider::class,
RecurrenceSetRepositoryServiceProvider::class,
];
/**
* @var string[]
*/
protected array $useCaseProviders = [
// Users
GetUserUseCaseServiceProvider::class,
DeleteUserUseCaseServiceProvider::class,
UpdateUserUseCaseServiceProvider::class,
CreateUserUseCaseServiceProvider::class,
GetAllUsersUseCaseServiceProvider::class,
// DoorUser
UserDoorAccessUseCaseServiceProvider::class,
// Groups
GetGroupUseCaseServiceProvider::class,
CreateGroupUseCaseServiceProvider::class,
DeleteGroupUseCaseServiceProvider::class,
UpdateGroupUseCaseServiceProvider::class,
GetGroupsUseCaseServiceProvider::class,
// GroupUser
GetUserGroupsUseCaseServiceProvider::class,
GetGroupUsersUseCaseServiceProvider::class,
AddUserToGroupUseCaseServiceProvider::class,
RemoveUserFromGroupUseCaseServiceProvider::class,
// DoorGroup
GetDoorGroupsUseCaseServiceProvider::class,
GetGroupDoorsUseCaseServiceProvider::class,
AddDoorToGroupUseCaseServiceProvider::class,
RemoveDoorFromGroupUseCaseServiceProvider::class,
// Door
AccessUseCaseServiceProvider::class,
UpdateBinaryUseCaseServiceProvider::class,
StatusResponseUseCaseServiceProvider::class,
DoorAuthenticateUseCaseServiceProvider::class,
// Doors
GetDoorUseCaseServiceProvider::class,
GetDoorsUseCaseServiceProvider::class,
CreateDoorUseCaseServiceProvider::class,
DeleteDoorUseCaseServiceProvider::class,
UpdateDoorUseCaseServiceProvider::class,
UserAuthenticateUseCaseServiceProvider::class,
GenerateDoorTokenUseCaseServiceProvider::class,
// Tokens
GetTokenUseCaseServiceProvider::class,
CreateTokenUseCaseServiceProvider::class,
ExpireTokenUseCaseServiceProvider::class,
UpdateTokenUseCaseServiceProvider::class,
GetTokensUseCaseServiceProvider::class,
TokenAuthenticateUseCaseServiceProvider::class,
// Attempts
GetAttemptsUseCaseServiceProvider::class,
// Entries
GetEntriesUseCaseServiceProvider::class,
// Schedule
ScheduleGetUseCaseServiceProvider::class,
SchedulesGetUseCaseServiceProvider::class,
ScheduleCreateUseCaseServiceProvider::class,
ScheduleUpdateUseCaseServiceProvider::class,
// Overrides
OverrideGetUseCaseServiceProvider::class,
OverridesGetUseCaseServiceProvider::class,
OverrideCreateUseCaseServiceProvider::class,
OverrideUpdateUseCaseServiceProvider::class,
// Commands
CommandServiceProvider::class,
];
/**
* Register any application services.
*
......@@ -176,16 +13,7 @@ class AppServiceProvider extends ServiceProvider
*/
public function register()
{
// We register gateways first, as use cases will generally use gateways
// Not that it actually matters because they are all deferred anyway
// and will all be registered before any need to be created.
foreach ($this->gatewayProviders as $gatewayProvider) {
$this->app->registerDeferredProvider($gatewayProvider);
}
foreach ($this->useCaseProviders as $useCaseProvider) {
$this->app->registerDeferredProvider($useCaseProvider);
}
//
}
/**
......
......@@ -186,6 +186,101 @@ return [
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
/*
* Gateway Providers
*/
Source\Authorization\AuthorizerServiceProvider::class,
Source\Gateways\Saml\SamlRepositoryServiceProvider::class,
Source\Gateways\Users\UsersRepositoryServiceProvider::class,
Source\Gateways\Doors\DoorsRepositoryServiceProvider::class,
Source\Gateways\Tokens\TokensRepositoryServiceProvider::class,
Source\Gateways\Groups\GroupsRepositoryServiceProvider::class,
Source\Gateways\Entries\EntriesRepositoryServiceProvider::class,
Source\Gateways\Attempts\AttemptsRepositoryServiceProvider::class,
Source\Gateways\DoorUser\DoorUserRepositoryServiceProvider::class,
Source\Gateways\Schedules\SchedulesRepositoryServiceProvider::class,
Source\Gateways\DoorGroup\DoorGroupRepositoryServiceProvider::class,
Source\Gateways\GroupUser\GroupUserRepositoryServiceProvider::class,
Source\Gateways\Overrides\OverridesRepositoryServiceProvider::class,
Source\Gateways\Filesystem\FilesystemRepositoryServiceProvider::class,
Source\Gateways\DoorSchedule\DoorScheduleRepositoryServiceProvider::class,
Source\Gateways\RecurrenceSet\RecurrenceSetRepositoryServiceProvider::class,
/*
* Use case providers
*/
// Users
Source\UseCases\Users\GetUser\GetUserUseCaseServiceProvider::class,
Source\UseCases\Users\GetUsers\GetAllUsersUseCaseServiceProvider::class,
Source\UseCases\Users\CreateUser\CreateUserUseCaseServiceProvider::class,
Source\UseCases\Users\DeleteUser\DeleteUserUseCaseServiceProvider::class,
Source\UseCases\Users\UpdateUser\UpdateUserUseCaseServiceProvider::class,
Source\UseCases\Users\Authenticate\AuthenticateUseCaseServiceProvider::class,
// DoorUser
Source\UseCases\DoorUser\UserDoorAccess\UserDoorAccessUseCaseServiceProvider::class,
// Groups
Source\UseCases\Groups\GetGroup\GetGroupUseCaseServiceProvider::class,
Source\UseCases\Groups\CreateGroup\CreateGroupUseCaseServiceProvider::class,
Source\UseCases\Groups\DeleteGroup\DeleteGroupUseCaseServiceProvider::class,
Source\UseCases\Groups\UpdateGroup\UpdateGroupUseCaseServiceProvider::class,
Source\UseCases\Groups\GetGroups\GetGroupsUseCaseServiceProvider::class,
// GroupUser
Source\UseCases\GroupUser\GetUserGroups\GetUserGroupsUseCaseServiceProvider::class,
Source\UseCases\GroupUser\GetGroupUsers\GetGroupUsersUseCaseServiceProvider::class,
Source\UseCases\GroupUser\AddUserToGroup\AddUserToGroupUseCaseServiceProvider::class,
Source\UseCases\GroupUser\RemoveUserFromGroup\RemoveUserFromGroupUseCaseServiceProvider::class,
// DoorGroup
Source\UseCases\DoorGroup\GetDoorGroups\GetDoorGroupsUseCaseServiceProvider::class,
Source\UseCases\DoorGroup\GetGroupDoors\GetGroupDoorsUseCaseServiceProvider::class,
Source\UseCases\DoorGroup\AddDoorToGroup\AddDoorToGroupUseCaseServiceProvider::class,
Source\UseCases\DoorGroup\RemoveDoorFromGroup\RemoveDoorFromGroupUseCaseServiceProvider::class,
// Door
Source\UseCases\Door\Access\AccessUseCaseServiceProvider::class,
Source\UseCases\Door\Authenticate\AuthenticateUseCaseServiceProvider::class,
Source\UseCases\Door\UpdateBinary\UpdateBinaryUseCaseServiceProvider::class,
Source\UseCases\Door\StatusResponse\StatusResponseUseCaseServiceProvider::class,
// Doors
Source\UseCases\Doors\GetDoor\GetDoorUseCaseServiceProvider::class,
Source\UseCases\Doors\GetDoors\GetDoorsUseCaseServiceProvider::class,
Source\UseCases\Doors\CreateDoor\CreateDoorUseCaseServiceProvider::class,
Source\UseCases\Doors\DeleteDoor\DeleteDoorUseCaseServiceProvider::class,
Source\UseCases\Doors\UpdateDoor\UpdateDoorUseCaseServiceProvider::class,
Source\UseCases\Doors\GenerateDoorToken\GenerateDoorTokenUseCaseServiceProvider::class,
// Tokens
Source\UseCases\Tokens\GetToken\GetTokenUseCaseServiceProvider::class,
Source\UseCases\Tokens\GetTokens\GetTokensUseCaseServiceProvider::class,
Source\UseCases\Tokens\CreateToken\CreateTokenUseCaseServiceProvider::class,
Source\UseCases\Tokens\ExpireToken\ExpireTokenUseCaseServiceProvider::class,
Source\UseCases\Tokens\UpdateToken\UpdateTokenUseCaseServiceProvider::class,
Source\UseCases\Token\Authenticate\AuthenticateUseCaseServiceProvider::class,
// Attempts
Source\UseCases\Attempts\GetAttempts\GetAttemptsUseCaseServiceProvider::class,
// Entries
Source\UseCases\Entries\GetEntries\GetEntriesUseCaseServiceProvider::class,
// Schedule
Source\UseCases\Schedules\ScheduleGet\ScheduleGetUseCaseServiceProvider::class,
Source\UseCases\Schedules\SchedulesGet\SchedulesGetUseCaseServiceProvider::class,
Source\UseCases\Schedules\ScheduleCreate\ScheduleCreateUseCaseServiceProvider::class,
Source\UseCases\Schedules\ScheduleUpdate\ScheduleUpdateUseCaseServiceProvider::class,
// Overrides
Source\UseCases\Overrides\OverrideGet\OverrideGetUseCaseServiceProvider::class,
Source\UseCases\Overrides\OverridesGet\OverridesGetUseCaseServiceProvider::class,
Source\UseCases\Overrides\OverrideCreate\OverrideCreateUseCaseServiceProvider::class,
Source\UseCases\Overrides\OverrideUpdate\OverrideUpdateUseCaseServiceProvider::class,
// Commands
Source\UseCases\Door\Commands\CommandServiceProvider::class,
],
/*
......@@ -200,7 +295,6 @@ return [
*/
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Arr' => Illuminate\Support\Arr::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
......@@ -236,7 +330,5 @@ return [
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
],
];
......@@ -15,9 +15,7 @@ use App\Http\Controllers\AuthController;
|
*/
Route::get('/', static function () {
return new JsonResponse(['welcome' => 'Welcome to the elock API.']);
})->name('welcome');
Route::get('/', [AuthController::class, 'welcome'])->name('welcome');
Route::get('login', [AuthController::class, 'samlLogin'])->name('saml.login');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment