1
0
Fork 0
mirror of synced 2024-06-18 18:54:55 +12:00

Added yaml support

This commit is contained in:
Eldad Fux 2020-05-16 14:28:26 +03:00
parent 2c1df141dc
commit dbab79fa54
5 changed files with 46 additions and 3 deletions

View file

@ -84,7 +84,7 @@ RUN \
add-apt-repository ppa:certbot/certbot && \
apt-get update && \
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
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 && \

View file

@ -175,7 +175,7 @@ $utopia->get('/v1/projects/:projectId/usage')
],
'last30' => [
'start' => DateTime::createFromFormat('U', strtotime('-30 days')),
'end' => DateTime::createFromFormat('U', strtotime('today')),
'end' => DateTime::createFromFormat('U', strtotime('tomorrow')),
'group' => '1d',
],
'last90' => [

View file

@ -13,7 +13,6 @@ if (file_exists(__DIR__.'/../vendor/autoload.php')) {
use Utopia\App;
use Utopia\Request;
use Utopia\Response;
use Utopia\Config\Config;
use Utopia\Locale\Locale;
use Utopia\Registry\Registry;
@ -23,6 +22,7 @@ use Appwrite\Database\Document;
use Appwrite\Database\Validator\Authorization;
use Appwrite\Database\Adapter\MySQL as MySQLAdapter;
use Appwrite\Database\Adapter\Redis as RedisAdapter;
use Appwrite\Response\Response;
use PHPMailer\PHPMailer\PHPMailer;
const APP_NAME = 'Appwrite';

View file

@ -23,6 +23,7 @@
"ext-imagick": "*",
"ext-mbstring": "*",
"ext-json": "*",
"ext-yaml": "*",
"ext-dom": "*",
"ext-redis": "*",
"ext-pdo": "*",

View 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))
;
}
}