mirror of
https://github.com/getnamingo/registry.git
synced 2025-08-12 12:29:20 +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
|
@ -79,9 +79,13 @@ cp.example.com {
|
||||||
file_server
|
file_server
|
||||||
tls your-email@example.com
|
tls your-email@example.com
|
||||||
log {
|
log {
|
||||||
output file /var/log/caddy/cp_errors.log
|
output file /var/log/caddy/access.log
|
||||||
format console
|
format console
|
||||||
}
|
}
|
||||||
|
log {
|
||||||
|
output file /var/log/caddy/error.log
|
||||||
|
level ERROR
|
||||||
|
}
|
||||||
# Adminer Configuration
|
# Adminer Configuration
|
||||||
route /adminer.php* {
|
route /adminer.php* {
|
||||||
root * /usr/share/adminer
|
root * /usr/share/adminer
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
"filp/whoops": "^2.14.6",
|
"filp/whoops": "^2.14.6",
|
||||||
"imefisto/psr-swoole-native": "^1.1",
|
"imefisto/psr-swoole-native": "^1.1",
|
||||||
"chubbyphp/chubbyphp-static-file": "^1.2",
|
"chubbyphp/chubbyphp-static-file": "^1.2",
|
||||||
"lasserafn/php-initial-avatar-generator": "^4.2"
|
"lasserafn/php-initial-avatar-generator": "^4.2",
|
||||||
|
"mevdschee/php-crud-api": "^2.14"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|
12762
cp/public/api.php
12762
cp/public/api.php
File diff suppressed because it is too large
Load diff
|
@ -6,7 +6,10 @@ use App\Controllers\ProfileController;
|
||||||
use App\Middleware\AuthMiddleware;
|
use App\Middleware\AuthMiddleware;
|
||||||
use App\Middleware\GuestMiddleware;
|
use App\Middleware\GuestMiddleware;
|
||||||
use Slim\Exception\HttpNotFoundException;
|
use Slim\Exception\HttpNotFoundException;
|
||||||
|
use Nyholm\Psr7\ServerRequest;
|
||||||
use Nyholm\Psr7\Response;
|
use Nyholm\Psr7\Response;
|
||||||
|
use Tqdev\PhpCrudApi\Api;
|
||||||
|
use Tqdev\PhpCrudApi\Config\Config;
|
||||||
|
|
||||||
$app->get('/', HomeController::class .':index')->setName('index');
|
$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');
|
$route->post('/change-password', PasswordController::class . ':changePassword')->setName('change.password');
|
||||||
})->add(new AuthMiddleware($container));
|
})->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) {
|
$app->add(function (Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Server\RequestHandlerInterface $handler) {
|
||||||
try {
|
try {
|
||||||
return $handler->handle($request);
|
return $handler->handle($request);
|
||||||
|
@ -48,3 +67,5 @@ $app->add(function (Psr\Http\Message\ServerRequestInterface $request, Psr\Http\S
|
||||||
return $response->withStatus(404);
|
return $response->withStatus(404);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$app->addErrorMiddleware(true, true, true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue