2023-03-17 14:33:48 +00:00
|
|
|
<?php
|
|
|
|
|
2024-07-01 14:26:50 +00:00
|
|
|
use App\Http\Controllers\Api\ApplicationsController;
|
|
|
|
use App\Http\Controllers\Api\DatabasesController;
|
|
|
|
use App\Http\Controllers\Api\DeployController;
|
2024-07-06 12:34:15 +00:00
|
|
|
use App\Http\Controllers\Api\OtherController;
|
2024-07-01 14:26:50 +00:00
|
|
|
use App\Http\Controllers\Api\ProjectController;
|
|
|
|
use App\Http\Controllers\Api\ResourcesController;
|
|
|
|
use App\Http\Controllers\Api\SecurityController;
|
|
|
|
use App\Http\Controllers\Api\ServersController;
|
2024-07-02 14:12:04 +00:00
|
|
|
use App\Http\Controllers\Api\ServicesController;
|
2024-07-01 14:26:50 +00:00
|
|
|
use App\Http\Controllers\Api\TeamController;
|
|
|
|
use App\Http\Middleware\ApiAllowed;
|
2024-07-02 14:12:04 +00:00
|
|
|
use App\Http\Middleware\IgnoreReadOnlyApiToken;
|
2024-07-02 10:15:58 +00:00
|
|
|
use App\Http\Middleware\OnlyRootApiToken;
|
2023-03-17 14:33:48 +00:00
|
|
|
use Illuminate\Support\Facades\Route;
|
2024-01-25 12:45:17 +00:00
|
|
|
|
2024-07-06 12:34:15 +00:00
|
|
|
Route::get('/health', [OtherController::class, 'healthcheck']);
|
|
|
|
Route::post('/feedback', [OtherController::class, 'feedback']);
|
2024-02-16 20:56:38 +00:00
|
|
|
|
2023-10-20 12:51:01 +00:00
|
|
|
Route::group([
|
2024-07-02 10:15:58 +00:00
|
|
|
'middleware' => ['auth:sanctum', OnlyRootApiToken::class],
|
2024-06-10 20:43:34 +00:00
|
|
|
'prefix' => 'v1',
|
2024-07-01 14:26:50 +00:00
|
|
|
], function () {
|
2024-07-06 12:34:15 +00:00
|
|
|
Route::get('/enable', [OtherController::class, 'enable_api']);
|
|
|
|
Route::get('/disable', [OtherController::class, 'disable_api']);
|
2024-07-01 14:26:50 +00:00
|
|
|
});
|
|
|
|
Route::group([
|
|
|
|
'middleware' => ['auth:sanctum', ApiAllowed::class],
|
|
|
|
'prefix' => 'v1',
|
2023-10-20 12:51:01 +00:00
|
|
|
], function () {
|
2024-07-06 12:34:15 +00:00
|
|
|
Route::get('/version', [OtherController::class, 'version']);
|
2024-03-07 11:22:18 +00:00
|
|
|
|
2024-07-01 14:26:50 +00:00
|
|
|
Route::get('/teams', [TeamController::class, 'teams']);
|
|
|
|
Route::get('/teams/current', [TeamController::class, 'current_team']);
|
|
|
|
Route::get('/teams/current/members', [TeamController::class, 'current_team_members']);
|
|
|
|
Route::get('/teams/{id}', [TeamController::class, 'team_by_id']);
|
|
|
|
Route::get('/teams/{id}/members', [TeamController::class, 'members_by_id']);
|
|
|
|
|
|
|
|
Route::get('/projects', [ProjectController::class, 'projects']);
|
|
|
|
Route::get('/projects/{uuid}', [ProjectController::class, 'project_by_uuid']);
|
|
|
|
Route::get('/projects/{uuid}/{environment_name}', [ProjectController::class, 'environment_details']);
|
|
|
|
|
|
|
|
Route::get('/security/keys', [SecurityController::class, 'keys']);
|
2024-07-02 14:12:04 +00:00
|
|
|
Route::post('/security/keys', [SecurityController::class, 'create_key'])->middleware([IgnoreReadOnlyApiToken::class]);
|
2024-07-01 14:26:50 +00:00
|
|
|
|
|
|
|
Route::get('/security/keys/{uuid}', [SecurityController::class, 'key_by_uuid']);
|
2024-07-02 14:12:04 +00:00
|
|
|
Route::patch('/security/keys/{uuid}', [SecurityController::class, 'update_key'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::delete('/security/keys/{uuid}', [SecurityController::class, 'delete_key'])->middleware([IgnoreReadOnlyApiToken::class]);
|
2024-07-01 14:26:50 +00:00
|
|
|
|
2024-07-02 14:12:04 +00:00
|
|
|
Route::match(['get', 'post'], '/deploy', [DeployController::class, 'deploy'])->middleware([IgnoreReadOnlyApiToken::class]);
|
2024-07-01 14:26:50 +00:00
|
|
|
Route::get('/deployments', [DeployController::class, 'deployments']);
|
|
|
|
Route::get('/deployments/{uuid}', [DeployController::class, 'deployment_by_uuid']);
|
|
|
|
|
|
|
|
Route::get('/servers', [ServersController::class, 'servers']);
|
|
|
|
Route::get('/servers/{uuid}', [ServersController::class, 'server_by_uuid']);
|
2024-07-03 11:13:38 +00:00
|
|
|
Route::get('/servers/{uuid}/domains', [ServersController::class, 'domains_by_server']);
|
|
|
|
Route::get('/servers/{uuid}/resources', [ServersController::class, 'resources_by_server']);
|
2024-03-07 11:22:18 +00:00
|
|
|
|
2024-07-01 14:26:50 +00:00
|
|
|
Route::get('/resources', [ResourcesController::class, 'resources']);
|
2024-06-20 12:07:24 +00:00
|
|
|
|
2024-07-01 14:26:50 +00:00
|
|
|
Route::get('/applications', [ApplicationsController::class, 'applications']);
|
2024-07-04 11:45:06 +00:00
|
|
|
Route::post('/applications/public', [ApplicationsController::class, 'create_public_application'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::post('/applications/private-github-app', [ApplicationsController::class, 'create_private_gh_app_application'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::post('/applications/private-deploy-key', [ApplicationsController::class, 'create_private_deploy_key_application'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::post('/applications/dockerfile', [ApplicationsController::class, 'create_dockerfile_application'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::post('/applications/dockerimage', [ApplicationsController::class, 'create_dockerimage_application'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::post('/applications/dockercompose', [ApplicationsController::class, 'create_dockercompose_application'])->middleware([IgnoreReadOnlyApiToken::class]);
|
2024-06-21 14:46:13 +00:00
|
|
|
|
2024-07-01 14:26:50 +00:00
|
|
|
Route::get('/applications/{uuid}', [ApplicationsController::class, 'application_by_uuid']);
|
2024-07-02 14:12:04 +00:00
|
|
|
Route::patch('/applications/{uuid}', [ApplicationsController::class, 'update_by_uuid'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::delete('/applications/{uuid}', [ApplicationsController::class, 'delete_by_uuid'])->middleware([IgnoreReadOnlyApiToken::class]);
|
2024-06-26 11:00:36 +00:00
|
|
|
|
2024-07-04 11:45:06 +00:00
|
|
|
Route::get('/applications/{uuid}/envs', [ApplicationsController::class, 'envs']);
|
2024-07-02 14:12:04 +00:00
|
|
|
Route::post('/applications/{uuid}/envs', [ApplicationsController::class, 'create_env'])->middleware([IgnoreReadOnlyApiToken::class]);
|
2024-07-09 11:19:21 +00:00
|
|
|
Route::patch('/applications/{uuid}/envs/bulk', [ApplicationsController::class, 'create_bulk_envs'])->middleware([IgnoreReadOnlyApiToken::class]);
|
2024-07-01 14:26:50 +00:00
|
|
|
Route::patch('/applications/{uuid}/envs', [ApplicationsController::class, 'update_env_by_uuid']);
|
2024-07-02 14:12:04 +00:00
|
|
|
Route::delete('/applications/{uuid}/envs/{env_uuid}', [ApplicationsController::class, 'delete_env_by_uuid'])->middleware([IgnoreReadOnlyApiToken::class]);
|
2024-06-26 11:00:36 +00:00
|
|
|
|
2024-07-02 14:12:04 +00:00
|
|
|
Route::match(['get', 'post'], '/applications/{uuid}/start', [ApplicationsController::class, 'action_deploy'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::match(['get', 'post'], '/applications/{uuid}/restart', [ApplicationsController::class, 'action_restart'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::match(['get', 'post'], '/applications/{uuid}/stop', [ApplicationsController::class, 'action_stop'])->middleware([IgnoreReadOnlyApiToken::class]);
|
2024-06-20 12:07:24 +00:00
|
|
|
|
2024-07-01 14:26:50 +00:00
|
|
|
Route::get('/databases', [DatabasesController::class, 'databases']);
|
2024-07-09 11:19:21 +00:00
|
|
|
Route::post('/databases/postgresql', [DatabasesController::class, 'create_database_postgresql'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::post('/databases/mysql', [DatabasesController::class, 'create_database_mysql'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::post('/databases/mariadb', [DatabasesController::class, 'create_database_mariadb'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::post('/databases/mongodb', [DatabasesController::class, 'create_database_mongodb'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::post('/databases/redis', [DatabasesController::class, 'create_database_redis'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::post('/databases/clickhouse', [DatabasesController::class, 'create_database_clickhouse'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::post('/databases/dragonfly', [DatabasesController::class, 'create_database_dragonfly'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::post('/databases/keydb', [DatabasesController::class, 'create_database_keydb'])->middleware([IgnoreReadOnlyApiToken::class]);
|
2024-07-02 14:12:04 +00:00
|
|
|
|
2024-07-01 14:26:50 +00:00
|
|
|
Route::get('/databases/{uuid}', [DatabasesController::class, 'database_by_uuid']);
|
2024-07-02 14:12:04 +00:00
|
|
|
Route::patch('/databases/{uuid}', [DatabasesController::class, 'update_by_uuid'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::delete('/databases/{uuid}', [DatabasesController::class, 'delete_by_uuid'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
|
|
|
|
Route::match(['get', 'post'], '/databases/{uuid}/start', [DatabasesController::class, 'action_deploy'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::match(['get', 'post'], '/databases/{uuid}/restart', [DatabasesController::class, 'action_restart'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::match(['get', 'post'], '/databases/{uuid}/stop', [DatabasesController::class, 'action_stop'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
|
|
|
|
Route::get('/services', [ServicesController::class, 'services']);
|
|
|
|
Route::post('/services', [ServicesController::class, 'create_service'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
|
|
|
|
Route::get('/services/{uuid}', [ServicesController::class, 'service_by_uuid']);
|
|
|
|
// Route::patch('/services/{uuid}', [ServicesController::class, 'update_by_uuid'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::delete('/services/{uuid}', [ServicesController::class, 'delete_by_uuid'])->middleware([IgnoreReadOnlyApiToken::class]);
|
2024-07-02 11:39:44 +00:00
|
|
|
|
2024-07-02 14:12:04 +00:00
|
|
|
Route::match(['get', 'post'], '/services/{uuid}/start', [ServicesController::class, 'action_deploy'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::match(['get', 'post'], '/services/{uuid}/restart', [ServicesController::class, 'action_restart'])->middleware([IgnoreReadOnlyApiToken::class]);
|
|
|
|
Route::match(['get', 'post'], '/services/{uuid}/stop', [ServicesController::class, 'action_stop'])->middleware([IgnoreReadOnlyApiToken::class]);
|
2024-06-28 13:05:37 +00:00
|
|
|
|
2024-07-04 11:45:06 +00:00
|
|
|
// Route::delete('/envs/{env_uuid}', [EnvironmentVariablesController::class, 'delete_env_by_uuid'])->middleware([IgnoreReadOnlyApiToken::class]);
|
2024-03-07 11:01:21 +00:00
|
|
|
|
2023-10-20 12:51:01 +00:00
|
|
|
});
|
2023-09-25 18:57:52 +00:00
|
|
|
|
2024-06-21 14:46:13 +00:00
|
|
|
Route::any('/{any}', function () {
|
2024-07-03 11:13:38 +00:00
|
|
|
return response()->json(['message' => 'Not found.', 'docs' => 'https://coolify.io/docs'], 404);
|
2024-02-16 20:56:38 +00:00
|
|
|
})->where('any', '.*');
|
|
|
|
|
|
|
|
// Route::middleware(['throttle:5'])->group(function () {
|
|
|
|
// Route::get('/unsubscribe/{token}', function () {
|
|
|
|
// try {
|
|
|
|
// $token = request()->token;
|
|
|
|
// $email = decrypt($token);
|
|
|
|
// if (!User::whereEmail($email)->exists()) {
|
|
|
|
// return redirect(RouteServiceProvider::HOME);
|
|
|
|
// }
|
|
|
|
// if (User::whereEmail($email)->first()->marketing_emails === false) {
|
|
|
|
// return 'You have already unsubscribed from marketing emails.';
|
|
|
|
// }
|
|
|
|
// User::whereEmail($email)->update(['marketing_emails' => false]);
|
|
|
|
// return 'You have been unsubscribed from marketing emails.';
|
|
|
|
// } catch (\Throwable $e) {
|
|
|
|
// return 'Something went wrong. Please try again or contact support.';
|
|
|
|
// }
|
|
|
|
// })->name('unsubscribe.marketing.emails');
|
|
|
|
// });
|