mirror of
https://github.com/getnamingo/registry.git
synced 2025-08-05 09:11:29 +02:00
Updated CP API to use composer
This commit is contained in:
parent
60228a3e7a
commit
8f87d621a1
4 changed files with 28 additions and 12764 deletions
|
@ -6,7 +6,10 @@ use App\Controllers\ProfileController;
|
|||
use App\Middleware\AuthMiddleware;
|
||||
use App\Middleware\GuestMiddleware;
|
||||
use Slim\Exception\HttpNotFoundException;
|
||||
use Nyholm\Psr7\ServerRequest;
|
||||
use Nyholm\Psr7\Response;
|
||||
use Tqdev\PhpCrudApi\Api;
|
||||
use Tqdev\PhpCrudApi\Config\Config;
|
||||
|
||||
$app->get('/', HomeController::class .':index')->setName('index');
|
||||
|
||||
|
@ -39,6 +42,22 @@ $app->group('', function ($route) {
|
|||
$route->post('/change-password', PasswordController::class . ':changePassword')->setName('change.password');
|
||||
})->add(new AuthMiddleware($container));
|
||||
|
||||
$app->any('/api[/{params:.*}]', function (
|
||||
ServerRequest $request,
|
||||
Response $response,
|
||||
$args
|
||||
) use ($container) {
|
||||
$config = new Config([
|
||||
'username' => 'database-user',
|
||||
'password' => 'database-pass',
|
||||
'database' => 'database-name',
|
||||
'basePath' => '/api',
|
||||
]);
|
||||
$api = new Api($config);
|
||||
$response = $api->handle($request);
|
||||
return $response;
|
||||
});
|
||||
|
||||
$app->add(function (Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Server\RequestHandlerInterface $handler) {
|
||||
try {
|
||||
return $handler->handle($request);
|
||||
|
@ -48,3 +67,5 @@ $app->add(function (Psr\Http\Message\ServerRequestInterface $request, Psr\Http\S
|
|||
return $response->withStatus(404);
|
||||
}
|
||||
});
|
||||
|
||||
$app->addErrorMiddleware(true, true, true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue