Fixed searching metadata/extra fields. Added system ENV.

This commit is contained in:
abdulmohsen
2024-03-05 17:19:58 +03:00
parent 93a3b6e0c0
commit c7a0379fa9
2 changed files with 38 additions and 2 deletions

View File

@@ -135,7 +135,7 @@ final class Index
);
}
if (preg_match('/[^a-zA-Z0-9_]/', $sField)) {
if (preg_match('/[^a-zA-Z0-9_\.]/', $sField)) {
return api_error(
'Invalid value for key query string expected value format is [a-zA-Z0-9_].',
HTTP_STATUS::HTTP_BAD_REQUEST
@@ -166,7 +166,7 @@ final class Index
);
}
if (preg_match('/[^a-zA-Z0-9_]/', $sField)) {
if (preg_match('/[^a-zA-Z0-9_\.]/', $sField)) {
return api_error(
'Invalid value for key query string expected value format is [a-zA-Z0-9_].',
HTTP_STATUS::HTTP_BAD_REQUEST

36
src/API/System/Env.php Normal file
View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace App\API\System;
use App\Libs\Attributes\Route\Get;
use App\Libs\HTTP_STATUS;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
#[Get(self::URL . '[/]', name: 'system.env')]
final class Env
{
public const URL = '%{api.prefix}/system/env';
public function __invoke(ServerRequestInterface $request, array $args = []): ResponseInterface
{
$response = [
'@self' => (string)$request->getUri()->withHost('')->withPort(0)->withScheme(''),
'data' => [],
];
foreach (getenv() as $key => $val) {
if (false === str_starts_with($key, 'WS_') && $key !== 'HTTP_PORT') {
continue;
}
$response['data'][] = [
'key' => $key,
'value' => $val,
];
}
return api_response($response, HTTP_STATUS::HTTP_OK, []);
}
}