Added yaml support
This commit is contained in:
parent
2c1df141dc
commit
dbab79fa54
5 changed files with 46 additions and 3 deletions
|
@ -84,7 +84,7 @@ RUN \
|
||||||
add-apt-repository ppa:certbot/certbot && \
|
add-apt-repository ppa:certbot/certbot && \
|
||||||
apt-get update && \
|
apt-get update && \
|
||||||
apt-get install -y --no-install-recommends --no-install-suggests htop supervisor php$PHP_VERSION php$PHP_VERSION-fpm \
|
apt-get install -y --no-install-recommends --no-install-suggests htop supervisor php$PHP_VERSION php$PHP_VERSION-fpm \
|
||||||
php$PHP_VERSION-mysqlnd php$PHP_VERSION-curl php$PHP_VERSION-imagick php$PHP_VERSION-mbstring php$PHP_VERSION-dom webp certbot && \
|
php$PHP_VERSION-mysqlnd php$PHP_VERSION-curl php$PHP_VERSION-imagick php$PHP_VERSION-mbstring php$PHP_VERSION-dom php$PHP_VERSION-yaml webp certbot && \
|
||||||
# Nginx
|
# Nginx
|
||||||
echo "deb http://nginx.org/packages/mainline/ubuntu/ bionic nginx" >> /etc/apt/sources.list.d/nginx.list && \
|
echo "deb http://nginx.org/packages/mainline/ubuntu/ bionic nginx" >> /etc/apt/sources.list.d/nginx.list && \
|
||||||
wget -q http://nginx.org/keys/nginx_signing.key && \
|
wget -q http://nginx.org/keys/nginx_signing.key && \
|
||||||
|
|
|
@ -175,7 +175,7 @@ $utopia->get('/v1/projects/:projectId/usage')
|
||||||
],
|
],
|
||||||
'last30' => [
|
'last30' => [
|
||||||
'start' => DateTime::createFromFormat('U', strtotime('-30 days')),
|
'start' => DateTime::createFromFormat('U', strtotime('-30 days')),
|
||||||
'end' => DateTime::createFromFormat('U', strtotime('today')),
|
'end' => DateTime::createFromFormat('U', strtotime('tomorrow')),
|
||||||
'group' => '1d',
|
'group' => '1d',
|
||||||
],
|
],
|
||||||
'last90' => [
|
'last90' => [
|
||||||
|
|
|
@ -13,7 +13,6 @@ if (file_exists(__DIR__.'/../vendor/autoload.php')) {
|
||||||
|
|
||||||
use Utopia\App;
|
use Utopia\App;
|
||||||
use Utopia\Request;
|
use Utopia\Request;
|
||||||
use Utopia\Response;
|
|
||||||
use Utopia\Config\Config;
|
use Utopia\Config\Config;
|
||||||
use Utopia\Locale\Locale;
|
use Utopia\Locale\Locale;
|
||||||
use Utopia\Registry\Registry;
|
use Utopia\Registry\Registry;
|
||||||
|
@ -23,6 +22,7 @@ use Appwrite\Database\Document;
|
||||||
use Appwrite\Database\Validator\Authorization;
|
use Appwrite\Database\Validator\Authorization;
|
||||||
use Appwrite\Database\Adapter\MySQL as MySQLAdapter;
|
use Appwrite\Database\Adapter\MySQL as MySQLAdapter;
|
||||||
use Appwrite\Database\Adapter\Redis as RedisAdapter;
|
use Appwrite\Database\Adapter\Redis as RedisAdapter;
|
||||||
|
use Appwrite\Response\Response;
|
||||||
use PHPMailer\PHPMailer\PHPMailer;
|
use PHPMailer\PHPMailer\PHPMailer;
|
||||||
|
|
||||||
const APP_NAME = 'Appwrite';
|
const APP_NAME = 'Appwrite';
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
"ext-imagick": "*",
|
"ext-imagick": "*",
|
||||||
"ext-mbstring": "*",
|
"ext-mbstring": "*",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
|
"ext-yaml": "*",
|
||||||
"ext-dom": "*",
|
"ext-dom": "*",
|
||||||
"ext-redis": "*",
|
"ext-redis": "*",
|
||||||
"ext-pdo": "*",
|
"ext-pdo": "*",
|
||||||
|
|
42
src/Appwrite/Response/Response.php
Normal file
42
src/Appwrite/Response/Response.php
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Appwrite\Response;
|
||||||
|
|
||||||
|
use Appwrite\Database\Document;
|
||||||
|
use Exception;
|
||||||
|
use Utopia\Response as UtopiaResponse;
|
||||||
|
|
||||||
|
class Response extends UtopiaResponse
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* HTTP content types
|
||||||
|
*/
|
||||||
|
const CONTENT_TYPE_YAML = 'application/x-yaml';
|
||||||
|
|
||||||
|
public function dynamic(Document $document)
|
||||||
|
{
|
||||||
|
# code...
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* YAML
|
||||||
|
*
|
||||||
|
* This helper is for sending YAML HTTP response.
|
||||||
|
* It sets relevant content type header ('application/x-yaml') and convert a PHP array ($data) to valid YAML using native yaml_parse
|
||||||
|
*
|
||||||
|
* @see https://en.wikipedia.org/wiki/YAML
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
*/
|
||||||
|
public function yaml(array $data)
|
||||||
|
{
|
||||||
|
if(!extension_loaded('yaml')) {
|
||||||
|
throw new Exception('Missing yaml extension. Learn more at: https://www.php.net/manual/en/book.yaml.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this
|
||||||
|
->setContentType(Response::CONTENT_TYPE_YAML)
|
||||||
|
->send(yaml_emit($data, YAML_UTF8_ENCODING))
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue