Skip to content

Add support for admin/databases creation through application api #5222

@CODEHUBHQ

Description

@CODEHUBHQ

Is there an existing feature request for this?

  • I have searched the existing issues before opening this feature request.

Describe the feature you would like to see.

It would be great if the panel has the ability to create admin/databases using api-application route instead of creating the database host manulally.

Describe the solution you'd like.

I think we can add the following to api-application route
in the file routes\api-application.php we can add Route::post('/', [Admin\DatabaseController::class, 'create']);

under Endpoint: /api/application/nodes and modify the create method instead of returning redirect response to be the same as the return response from this endpoint Route::post('/', [Application\Servers\DatabaseController::class, 'store']);

this way we can call api/application/nodes/admin/databases and create a the host database

Simple workaround was to add the following code to panel api-application.

1- routes/api-application.php

// added use admin controller at the top
use Pterodactyl\Http\Controllers\Admin;

/*
|--------------------------------------------------------------------------
| Node Controller Routes
|--------------------------------------------------------------------------
|
| Endpoint: /api/application/nodes
|
*/
Route::group(['prefix' => '/nodes'], function () {
    // databases
    Route::post('/admin/databases', [Admin\DatabaseController::class, 'createdb']);
    Route::delete('/admin/databases/{host:id}', [Admin\DatabaseController::class, 'deletedb']);

    ... the rest of the code
});

2- app/Http/Controllers/Admin/DatabaseController.php

// added use Response at the top
use Illuminate\Http\Response;

/**
* Handle request to create a new database host.
*
* @throws \Throwable
*/
public function createdb(DatabaseHostFormRequest $request): Response
{
    $host = $this->creationService->handle($request->normalize());

    return response($host, 200);
}

/**
* Handle request to delete a database host.
*
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
*/
public function deletedb(int $host): Response
{
    $this->deletionService->handle($host);

    return response('', 204);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions