Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
353a2e7
Implement DB proxy
Meldiron Oct 16, 2023
2a8fb48
linter fix
Meldiron Oct 16, 2023
1fb9ad2
Remove leftover
Meldiron Oct 16, 2023
767361d
Add tests, address PR comments
Meldiron Oct 17, 2023
496ff76
Rename endpoints, add pool
Meldiron Oct 18, 2023
9a64f76
Remove memory limit
Meldiron Oct 18, 2023
bd8c0c2
Improve tests
Meldiron Oct 19, 2023
3146380
More auth roles tests
Meldiron Oct 19, 2023
02a45e6
PR review changes
Meldiron Nov 20, 2023
eeedcfc
PR review changes
Meldiron Nov 20, 2023
2b56bf9
Remove unnessessary endpoints
Meldiron Dec 9, 2023
2f54840
getDocument queries as string
fogelito Dec 9, 2023
c0cd587
Merge remote-tracking branch 'origin/dev' into dev
fogelito Dec 9, 2023
6fa0086
json_encode queries
fogelito Dec 9, 2023
0caa0a1
json_encode queries
fogelito Dec 9, 2023
6fb801b
json_encode queries
fogelito Dec 9, 2023
9a28cf2
Count endpoints.php
fogelito Dec 10, 2023
adcd7d3
Error exceptions
fogelito Dec 10, 2023
df736a6
No reference
fogelito Dec 10, 2023
43cc75c
Build command
fogelito Dec 13, 2023
9f76dee
composer.lock
fogelito Dec 13, 2023
0477586
PR review changes
Meldiron Jan 3, 2024
9755039
Fix failinig tests
Meldiron Jan 3, 2024
a8ae3a3
Changes after HTTP and Auth refactor
Meldiron Jan 27, 2024
c8adf31
Rename to data API
Meldiron Jan 29, 2024
b12bc38
Update readme
Meldiron Jan 29, 2024
4ea8dc1
Rework to have 1 endpoint only
Meldiron Feb 22, 2024
6aa2492
Fix CI/CD tests
Meldiron Feb 22, 2024
c42c4ae
Fix document convertion
Meldiron Feb 22, 2024
b44c0e9
Add support for Query
Meldiron Feb 22, 2024
a369456
WIP: Update to raw queries
Meldiron Feb 23, 2024
44a8f0b
Fix timeouts and serialize params
Meldiron Feb 27, 2024
8b194dc
Fix code quality
Meldiron Feb 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
UTOPIA_DATABASE_PROXY_SECRET=proxy-secret-key
UTOPIA_DATABASE_PROXY_SECRET_CONNECTIONS=default=mariadb://root:password@mariadb:3306/appwrite
16 changes: 16 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "CodeQL"

on: [pull_request]
jobs:
lint:
name: CodeQL
runs-on: ubuntu-latest

steps:
- name: Check out the repo
uses: actions/checkout@v2

- name: Run CodeQL
run: |
docker run --rm -v $PWD:/app composer sh -c \
"composer install --profile --ignore-platform-reqs && composer check"
16 changes: 16 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "Linter"
Comment thread
Meldiron marked this conversation as resolved.

on: [pull_request]
jobs:
lint:
name: Linter
runs-on: ubuntu-latest

steps:
- name: Check out the repo
uses: actions/checkout@v2

- name: Run Linter
run: |
docker run --rm -v $PWD:/app composer sh -c \
"composer install --profile --ignore-platform-reqs && composer lint"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/vendor/
/.idea/
.phpunit.result.cache
10 changes: 10 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
tasks:
- name: open-runtimes/proxy
init: |
docker compose pull
docker compose build
composer install --ignore-platform-reqs
vscode:
extensions:
- ms-azuretools.vscode-docker
- zobo.php-intellisense
78 changes: 78 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Install PHP libraries
FROM composer:2.0 as composer

WORKDIR /usr/local/src/

COPY composer.lock /usr/local/src/
COPY composer.json /usr/local/src/

RUN composer install --ignore-platform-reqs --optimize-autoloader \
--no-plugins --no-scripts --prefer-dist

# Prepare generic compiler
FROM php:8.0.18-cli-alpine3.15 as compile

ENV PHP_SWOOLE_VERSION=v4.8.10
Comment thread
Meldiron marked this conversation as resolved.
Outdated

RUN \
apk add --no-cache --virtual .deps \
make \
automake \
autoconf \
gcc \
g++ \
git \
openssl-dev

RUN docker-php-ext-install sockets

# Compile Swoole
FROM compile AS swoole

RUN \
git clone --depth 1 --branch $PHP_SWOOLE_VERSION https://github.com/swoole/swoole-src.git && \
cd swoole-src && \
phpize && \
./configure --enable-sockets --enable-http2 --enable-openssl && \
make && make install && \
cd ..

# Proxy
FROM php:8.0.18-cli-alpine3.15 as final

ARG UTOPIA_DATABASE_PROXY_VERSION
ENV UTOPIA_DATABASE_PROXY_VERSION=$UTOPIA_DATABASE_PROXY_VERSION

LABEL maintainer="team@appwrite.io"

RUN \
apk update \
&& apk add --no-cache --virtual .deps \
make \
automake \
autoconf \
gcc \
g++ \
curl-dev \
&& apk add --no-cache \
libstdc++ \
&& docker-php-ext-install sockets pdo_mysql \
Comment thread
Meldiron marked this conversation as resolved.
Outdated
&& apk del .deps \
&& rm -rf /var/cache/apk/*

WORKDIR /usr/local/

# Source code
COPY ./app /usr/local/app

# Extensions and libraries
COPY --from=composer /usr/local/src/vendor /usr/local/vendor
COPY --from=swoole /usr/local/lib/php/extensions/no-debug-non-zts-20200930/swoole.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/

COPY ./vendor/utopia-php/database/src/Database/Adapter/MariaDB.php /usr/local/vendor/utopia-php/database/src/Database/Adapter/MariaDB.php

RUN echo extension=swoole.so >> /usr/local/etc/php/conf.d/swoole.ini

EXPOSE 80

CMD [ "php", "app/http.php" ]
2 changes: 2 additions & 0 deletions _build.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- TODO: Convert this to real release process
docker build -t utopia-php/database-proxy:0.1.0 .
Comment thread
Meldiron marked this conversation as resolved.
Outdated
36 changes: 36 additions & 0 deletions app/Validator/Assoc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Utopia\DatabaseProxy\Validator;

use Utopia\Http\Validator\Assoc as FrameworkAssoc;

/**
* Extention of Assoc validator that allows greater length
* TODO: Add length param to original validator instead
Comment thread
Meldiron marked this conversation as resolved.
Outdated
*/
class Assoc extends FrameworkAssoc
{
/**
* Is valid
*
* Validation will pass when $value is valid assoc array.
*
* @param mixed $value
* @return bool
*/
public function isValid($value): bool
{
if (! \is_array($value)) {
return false;
}

$jsonString = \json_encode($value);
$jsonStringSize = \strlen($jsonString ? $jsonString : '');

if ($jsonStringSize > MAX_STRING_SIZE) {
return false;
}

return \array_keys($value) !== \range(0, \count($value) - 1);
}
}
Loading