1
0
Fork 0
mirror of synced 2024-06-22 04:30:29 +12:00

Merge branch '0.7.x' of github.com:appwrite/appwrite into feat-sdk-note

This commit is contained in:
Eldad Fux 2021-01-28 18:36:09 +02:00
commit 9167b2c480
28 changed files with 368 additions and 58 deletions

4
.env
View file

@ -32,8 +32,8 @@ _APP_STORAGE_LIMIT=10000000
_APP_FUNCTIONS_TIMEOUT=900
_APP_FUNCTIONS_CONTAINERS=10
_APP_FUNCTIONS_CPUS=1
_APP_FUNCTIONS_MEMORY=128
_APP_FUNCTIONS_MEMORY_SWAP=128
_APP_FUNCTIONS_MEMORY=256
_APP_FUNCTIONS_MEMORY_SWAP=256
_APP_MAINTENANCE_INTERVAL=86400
_APP_MAINTENANCE_RETENTION_EXECUTION=1209600
_APP_MAINTENANCE_RETENTION_ABUSE=86400

View file

@ -1,8 +1,12 @@
<?php
use Utopia\App;
use Utopia\System\System;
/**
* List of Appwrite Cloud Functions supported environments
*/
return [
$environments = [
'node-14.5' => [
'name' => 'Node.js',
'version' => '14.5',
@ -10,6 +14,7 @@ return [
'image' => 'appwrite/env-node-14.5:1.0.0',
'build' => '/usr/src/code/docker/environments/node-14.5',
'logo' => 'node.png',
'supports' => [System::X86, System::PPC, System::ARM],
],
'node-15.5' => [
'name' => 'Node.js',
@ -18,6 +23,7 @@ return [
'image' => 'appwrite/env-node-15.5:1.0.0',
'build' => '/usr/src/code/docker/environments/node-15.5',
'logo' => 'node.png',
'supports' => [System::X86, System::PPC, System::ARM],
],
'php-7.4' => [
'name' => 'PHP',
@ -26,6 +32,7 @@ return [
'image' => 'appwrite/env-php-7.4:1.0.0',
'build' => '/usr/src/code/docker/environments/php-7.4',
'logo' => 'php.png',
'supports' => [System::X86, System::PPC, System::ARM],
],
'php-8.0' => [
'name' => 'PHP',
@ -34,6 +41,7 @@ return [
'image' => 'appwrite/env-php-8.0:1.0.0',
'build' => '/usr/src/code/docker/environments/php-8.0',
'logo' => 'php.png',
'supports' => [System::X86, System::PPC, System::ARM],
],
'ruby-2.7' => [
'name' => 'Ruby',
@ -42,6 +50,7 @@ return [
'image' => 'appwrite/env-ruby-2.7:1.0.2',
'build' => '/usr/src/code/docker/environments/ruby-2.7',
'logo' => 'ruby.png',
'supports' => [System::X86, System::PPC, System::ARM],
],
'ruby-3.0' => [
'name' => 'Ruby',
@ -50,6 +59,7 @@ return [
'image' => 'appwrite/env-ruby-3.0:1.0.0',
'build' => '/usr/src/code/docker/environments/ruby-3.0',
'logo' => 'ruby.png',
'supports' => [System::X86, System::PPC, System::ARM],
],
'python-3.8' => [
'name' => 'Python',
@ -58,6 +68,7 @@ return [
'image' => 'appwrite/env-python-3.8:1.0.0',
'build' => '/usr/src/code/docker/environments/python-3.8',
'logo' => 'python.png',
'supports' => [System::X86, System::PPC, System::ARM],
],
'deno-1.2' => [
'name' => 'Deno',
@ -66,6 +77,7 @@ return [
'image' => 'appwrite/env-deno-1.2:1.0.0',
'build' => '/usr/src/code/docker/environments/deno-1.2',
'logo' => 'deno.png',
'supports' => [System::X86, System::PPC, System::ARM],
],
'deno-1.5' => [
'name' => 'Deno',
@ -74,6 +86,7 @@ return [
'image' => 'appwrite/env-deno-1.5:1.0.0',
'build' => '/usr/src/code/docker/environments/deno-1.5',
'logo' => 'deno.png',
'supports' => [System::X86, System::PPC, System::ARM],
],
'deno-1.6' => [
'name' => 'Deno',
@ -82,13 +95,44 @@ return [
'image' => 'appwrite/env-deno-1.6:1.0.0',
'build' => '/usr/src/code/docker/environments/deno-1.6',
'logo' => 'deno.png',
'supports' => [System::X86, System::PPC, System::ARM],
],
// 'dart-2.8' => [
// 'name' => 'Dart',
// 'version' => '2.8',
// 'base' => 'google/dart:2.8',
// 'image' => 'appwrite/env-dart:2.8',
// 'build' => '/usr/src/code/docker/environments/dart-2.8',
// 'logo' => 'dart.png',
// ],
];
'dart-2.10' => [
'name' => 'Dart',
'version' => '2.10',
'base' => 'google/dart:2.10',
'image' => 'appwrite/env-dart-2.10:1.0.0',
'build' => '/usr/src/code/docker/environments/dart-2.10',
'logo' => 'dart.png',
'supports' => [System::X86],
],
'dotnet-3.1' => [
'name' => '.NET',
'version' => '3.1',
'base' => 'mcr.microsoft.com/dotnet/runtime:3.1-alpine',
'image' => 'appwrite/env-dotnet-3.1:1.0.0',
'build' => '/usr/src/code/docker/environments/dotnet-3.1',
'logo' => 'dotnet.png',
'supports' => [System::X86, System::ARM],
],
'dotnet-5.0' => [
'name' => '.NET',
'version' => '5.0',
'base' => 'mcr.microsoft.com/dotnet/runtime:5.0-alpine',
'image' => 'appwrite/env-dotnet-5.0:1.0.0',
'build' => '/usr/src/code/docker/environments/dotnet-5.0',
'logo' => 'dotnet.png',
'supports' => [System::X86, System::ARM],
],
];
$allowList = empty(App::getEnv('_APP_FUNCTIONS_ENVS', null)) ? false : \explode(',', App::getEnv('_APP_FUNCTIONS_ENVS', null));
$environments = array_filter($environments, function ($environment, $key) use ($allowList) {
$isAllowed = $allowList && in_array($key, $allowList);
$isSupported = in_array(System::getArchEnum(), $environment["supports"]);
return $allowList ? ($isAllowed && $isSupported) : $isSupported;
}, ARRAY_FILTER_USE_BOTH);
return $environments;

View file

@ -1,5 +1,7 @@
<?php
use Utopia\Config\Config;
return [
[
'category' => 'General',
@ -22,7 +24,7 @@ return [
'question' => '',
],
[
'name' => '_APP_OPTIONS_FORCE_HTTPS',
'name' => '_APP_OPTIONS_FORCE_HTTPS',
'description' => 'Allows you to force HTTPS connection to your API. This feature redirects any HTTP call to HTTPS and adds the \'Strict-Transport-Security\' header to all HTTP responses. By default, set to \'disabled\'. To enable, set to \'enabled\'. This feature will work only when your ports are set to default 80 and 443.',
'introduction' => '',
'default' => 'enabled',
@ -51,7 +53,7 @@ return [
'introduction' => '',
'default' => 'localhost',
'required' => true,
'question' => "Enter a DNS A record hostname to serve as a CNAME for your custom domains.\nYou can use the same value as used for the Appwrite hostname.",
'question' => 'Enter a DNS A record hostname to serve as a CNAME for your custom domains.\nYou can use the same value as used for the Appwrite hostname.',
],
[
'name' => '_APP_CONSOLE_WHITELIST_EMAILS',
@ -63,7 +65,7 @@ return [
],
[
'name' => '_APP_CONSOLE_WHITELIST_DOMAINS',
'description' => "This option allows you to limit creation of users to Appwrite console for users sharing the same email domains. This option is very useful for team working with company emails domain.\n\nTo enable this option, pass a list of allowed email domains separated by a comma.",
'description' => 'This option allows you to limit creation of users to Appwrite console for users sharing the same email domains. This option is very useful for team working with company emails domain.\n\nTo enable this option, pass a list of allowed email domains separated by a comma.',
'introduction' => '',
'default' => '',
'required' => false,
@ -71,7 +73,7 @@ return [
],
[
'name' => '_APP_CONSOLE_WHITELIST_IPS',
'description' => "This last option allows you to limit creation of users in Appwrite console for users sharing the same set of IP addresses. This option is very useful for team working with a VPN service or a company IP.\n\nTo enable/activate this option, pass a list of allowed IP addresses separated by a comma.",
'description' => 'This last option allows you to limit creation of users in Appwrite console for users sharing the same set of IP addresses. This option is very useful for team working with a VPN service or a company IP.\n\nTo enable/activate this option, pass a list of allowed IP addresses separated by a comma.',
'introduction' => '',
'default' => '',
'required' => false,
@ -225,7 +227,7 @@ return [
],
[
'category' => 'SMTP',
'description' => "Appwrite is using an SMTP server for emailing your projects users and server admins. The SMTP env vars are used to allow Appwrite server to connect to the SMTP container.\n\nIf running in production, it might be easier to use a 3rd party SMTP server as it might be a little more difficult to set up a production SMTP server that will not send all your emails into your user's SPAM folder.",
'description' => 'Appwrite is using an SMTP server for emailing your projects users and server admins. The SMTP env vars are used to allow Appwrite server to connect to the SMTP container.\n\nIf running in production, it might be easier to use a 3rd party SMTP server as it might be a little more difficult to set up a production SMTP server that will not send all your emails into your user\'s SPAM folder.',
'variables' => [
[
'name' => '_APP_SMTP_HOST',
@ -347,7 +349,15 @@ return [
'name' => '_APP_FUNCTIONS_MEMORY_SWAP',
'description' => 'The maximum amount of swap memory a single cloud function is allowed to use in megabytes. The default value is 128.',
'introduction' => '0.7.0',
'default' => '128',
'default' => '256',
'required' => false,
'question' => '',
],
[
'name' => '_APP_FUNCTIONS_ENVS',
'description' => 'This option allows you to limit the available environments for cloud functions. This option is very useful for low-cost servers to safe disk space.\n\nTo enable/activate this option, pass a list of allowed environments separated by a comma.\n\nCurrently, supported environments are: ' . \implode(', ', \array_keys(Config::getParam('providers'))),
'introduction' => '0.7.0',
'default' => 'node-14.5,deno-1.6,php-7.4,python-3.8,ruby-3.0,dotnet-5.0',
'required' => false,
'question' => '',
],

View file

@ -6,8 +6,8 @@ use Appwrite\Database\Validator\Authorization;
use Appwrite\Database\Validator\UID;
use Utopia\Storage\Storage;
use Utopia\Storage\Validator\File;
use Utopia\Storage\Validator\FileExt;
use Utopia\Storage\Validator\FileSize;
use Utopia\Storage\Validator\FileType;
use Utopia\Storage\Validator\Upload;
use Appwrite\Utopia\Response;
use Appwrite\Task\Validator\Cron;
@ -455,7 +455,7 @@ App::post('/v1/functions/:functionId/tags')
$file = $request->getFiles('code');
$device = Storage::getDevice('functions');
$fileType = new FileType([FileType::FILE_TYPE_GZIP]);
$fileExt = new FileExt([FileExt::TYPE_GZIP]);
$fileSize = new FileSize(App::getEnv('_APP_STORAGE_LIMIT', 0));
$upload = new Upload();
@ -468,10 +468,9 @@ App::post('/v1/functions/:functionId/tags')
$file['tmp_name'] = (\is_array($file['tmp_name']) && isset($file['tmp_name'][0])) ? $file['tmp_name'][0] : $file['tmp_name'];
$file['size'] = (\is_array($file['size']) && isset($file['size'][0])) ? $file['size'][0] : $file['size'];
// Check if file type is allowed (feature for project settings?)
// if (!$fileType->isValid($file['tmp_name'])) {
// throw new Exception('File type not allowed', 400);
// }
if (!$fileExt->isValid($file['name'])) { // Check if file type is allowed
throw new Exception('File type not allowed', 400);
}
if (!$fileSize->isValid($file['size'])) { // Check if file size is exceeding allowed limit
throw new Exception('File size not allowed', 400);

View file

@ -85,6 +85,7 @@ services:
- _APP_FUNCTIONS_CPUS
- _APP_FUNCTIONS_MEMORY
- _APP_FUNCTIONS_MEMORY_SWAP
- _APP_FUNCTIONS_ENVS
appwrite-worker-usage:
image: appwrite/appwrite:<?php echo $version."\n"; ?>

View file

@ -335,7 +335,7 @@ class FunctionsV1
\array_walk($vars, function (&$value, $key) {
$key = $this->filterEnvKey($key);
$value = \escapeshellarg((empty($value)) ? 'null' : $value);
$value = "\t\t\t--env {$key}={$value} \\";
$value = "--env {$key}={$value}";
});
$tagPath = $tag->getAttribute('path', '');
@ -387,20 +387,20 @@ class FunctionsV1
$executionStart = \microtime(true);
$executionTime = \time();
$exitCode = Console::execute("docker run \
-d \
--entrypoint=\"\" \
--cpus=".App::getEnv('_APP_FUNCTIONS_CPUS', '1')." \
--memory=".App::getEnv('_APP_FUNCTIONS_MEMORY', '128')."m \
--memory-swap=".App::getEnv('_APP_FUNCTIONS_MEMORY_SWAP', '128')."m \
--name={$container} \
--label appwrite-type=function \
--label appwrite-created=".$executionTime." \
--volume {$tagPathTargetDir}:/tmp:rw \
--workdir /usr/local/src \
".\implode("\n", $vars)."
{$environment['image']} \
sh -c 'mv /tmp/code.tar.gz /usr/local/src/code.tar.gz && tar -zxf /usr/local/src/code.tar.gz --strip 1 && rm /usr/local/src/code.tar.gz && tail -f /dev/null'"
$exitCode = Console::execute("docker run ".
" -d".
" --entrypoint=\"\"".
" --cpus=".App::getEnv('_APP_FUNCTIONS_CPUS', '1').
" --memory=".App::getEnv('_APP_FUNCTIONS_MEMORY', '256')."m".
" --memory-swap=".App::getEnv('_APP_FUNCTIONS_MEMORY_SWAP', '256')."m".
" --name={$container}".
" --label appwrite-type=function".
" --label appwrite-created={$executionTime}".
" --volume {$tagPathTargetDir}:/tmp:rw".
" --workdir /usr/local/src".
" ".\implode(" ", $vars).
" {$environment['image']}".
" sh -c 'mv /tmp/code.tar.gz /usr/local/src/code.tar.gz && tar -zxf /usr/local/src/code.tar.gz --strip 1 && rm /usr/local/src/code.tar.gz && tail -f /dev/null'"
, '', $stdout, $stderr, 30);
$executionEnd = \microtime(true);
@ -430,11 +430,8 @@ class FunctionsV1
$executionStart = \microtime(true);
$exitCode = Console::execute("docker exec \
".\implode("\n", $vars)."
{$container} \
{$command}"
, '', $stdout, $stderr, $function->getAttribute('timeout', (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900)));
$exitCode = Console::execute("docker exec ".\implode(" ", $vars)." {$container} {$command}"
, '', $stdout, $stderr, $function->getAttribute('timeout', (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900)));
$executionEnd = \microtime(true);
$executionTime = ($executionEnd - $executionStart);

View file

@ -45,7 +45,8 @@
"utopia-php/preloader": "0.2.*",
"utopia-php/domains": "0.2.*",
"utopia-php/swoole": "0.2.*",
"utopia-php/storage": "0.1.*",
"utopia-php/system": "0.3.*",
"utopia-php/storage": "0.2.*",
"resque/php-resque": "1.3.6",
"matomo/device-detector": "3.13.0",

77
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "dfdd9cb73ec7817c0d94d126b9a2173b",
"content-hash": "f83cd9bbcc8c8361622aba6313f81e28",
"packages": [
{
"name": "adhocore/jwt",
@ -1697,16 +1697,16 @@
},
{
"name": "utopia-php/storage",
"version": "0.1.0",
"version": "0.2.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/storage.git",
"reference": "00e9045cee6bd1ec1d1f27329c329494ef420c19"
"reference": "27bfd663c9b2a17ac0911522a87f42bee834df95"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/storage/zipball/00e9045cee6bd1ec1d1f27329c329494ef420c19",
"reference": "00e9045cee6bd1ec1d1f27329c329494ef420c19",
"url": "https://api.github.com/repos/utopia-php/storage/zipball/27bfd663c9b2a17ac0911522a87f42bee834df95",
"reference": "27bfd663c9b2a17ac0911522a87f42bee834df95",
"shasum": ""
},
"require": {
@ -1743,9 +1743,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/storage/issues",
"source": "https://github.com/utopia-php/storage/tree/0.1.0"
"source": "https://github.com/utopia-php/storage/tree/0.2.0"
},
"time": "2021-01-22T07:27:20+00:00"
"time": "2021-01-27T12:21:27+00:00"
},
{
"name": "utopia-php/swoole",
@ -1802,6 +1802,61 @@
"source": "https://github.com/utopia-php/swoole/tree/0.2.0"
},
"time": "2020-10-29T12:42:38+00:00"
},
{
"name": "utopia-php/system",
"version": "0.3.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/system.git",
"reference": "63a4f2ea06a60ed82b8904e24b4754df0f77fef2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/system/zipball/63a4f2ea06a60ed82b8904e24b4754df0f77fef2",
"reference": "63a4f2ea06a60ed82b8904e24b4754df0f77fef2",
"shasum": ""
},
"require": {
"php": ">=7.4"
},
"require-dev": {
"phpunit/phpunit": "^9.3",
"vimeo/psalm": "4.0.1"
},
"type": "library",
"autoload": {
"psr-4": {
"Utopia\\System\\": "src/System"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Eldad Fux",
"email": "eldad@appwrite.io"
},
{
"name": "Torsten Dittmann",
"email": "torsten@appwrite.io"
}
],
"description": "A simple library for obtaining information about the host's system.",
"keywords": [
"framework",
"php",
"system",
"upf",
"utopia"
],
"support": {
"issues": "https://github.com/utopia-php/system/issues",
"source": "https://github.com/utopia-php/system/tree/0.3.0"
},
"time": "2021-01-24T11:28:55+00:00"
}
],
"packages-dev": [
@ -3782,12 +3837,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git",
"reference": "5a39e6c8994048403e326298f0b1bda7eb1ea127"
"reference": "66776aea976481264dbaeef1b80c72845711473c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5a39e6c8994048403e326298f0b1bda7eb1ea127",
"reference": "5a39e6c8994048403e326298f0b1bda7eb1ea127",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/66776aea976481264dbaeef1b80c72845711473c",
"reference": "66776aea976481264dbaeef1b80c72845711473c",
"shasum": ""
},
"require": {
@ -3849,7 +3904,7 @@
"type": "github"
}
],
"time": "2021-01-27T14:14:42+00:00"
"time": "2021-01-27T12:55:14+00:00"
},
{
"name": "sebastian/complexity",

View file

@ -108,6 +108,7 @@ services:
- _APP_FUNCTIONS_CPUS
- _APP_FUNCTIONS_MEMORY
- _APP_FUNCTIONS_MEMORY_SWAP
- _APP_FUNCTIONS_ENVS
appwrite-worker-usage:
entrypoint: worker-usage

View file

@ -29,3 +29,12 @@ docker buildx build --platform linux/amd64,linux/arm64,linux/386,linux/ppc64le -
echo 'Ruby 3.0...'
docker buildx build --platform linux/amd64,linux/arm64,linux/386,linux/ppc64le -t appwrite/env-ruby-3.0:1.0.0 ./docker/environments/ruby-3.0/ --push
echo 'Dart 2.10...'
docker buildx build --platform linux/amd64 -t appwrite/env-dart-2.10:1.0.0 ./docker/environments/dart-2.10/ --push
echo '.NET 3.1...'
docker buildx build --platform linux/amd64,linux/arm64 -t appwrite/env-dotnet-3.1:1.0.0 ./docker/environments/dotnet-3.1/ --push
echo '.NET 5.0...'
docker buildx build --platform linux/amd64,linux/arm64 -t appwrite/env-dotnet-5.0:1.0.0 ./docker/environments/dotnet-5.0/ --push

View file

@ -0,0 +1,9 @@
FROM google/dart:2.10
LABEL maintainer="team@appwrite.io"
RUN apt-get update -y && apt-get install -y tar
WORKDIR /usr/local/src/
ENV PUB_CACHE=/usr/local/src/.appwrite

View file

@ -0,0 +1,7 @@
FROM mcr.microsoft.com/dotnet/runtime:3.1-alpine
LABEL maintainer="team@appwrite.io"
RUN apk add tar
WORKDIR /usr/local/src/

View file

@ -0,0 +1,7 @@
FROM mcr.microsoft.com/dotnet/runtime:5.0-alpine
LABEL maintainer="team@appwrite.io"
RUN apk add tar
WORKDIR /usr/local/src/

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View file

@ -535,9 +535,34 @@ class FunctionsCustomServerTest extends Scope
'command' => 'deno run --allow-env index.ts',
'timeout' => 15,
],
[
'language' => 'Dart',
'version' => '2.10',
'name' => 'dart-2.10',
'code' => $functions.'/dart.tar.gz',
'command' => 'dart main.dart',
'timeout' => 15,
],
[
'language' => '.NET',
'version' => '3.1',
'name' => 'dotnet-3.1',
'code' => $functions.'/dotnet-3.1.tar.gz',
'command' => 'dotnet dotnet.dll',
'timeout' => 15,
],
[
'language' => '.NET',
'version' => '5.0',
'name' => 'dotnet-5.0',
'code' => $functions.'/dotnet-5.0.tar.gz',
'command' => 'dotnet dotnet.dll',
'timeout' => 15,
],
];
sleep(count($envs) * 20);
fwrite(STDERR, ".");
/**
* Test for SUCCESS
@ -617,7 +642,7 @@ class FunctionsCustomServerTest extends Scope
$executionId = $execution['body']['$id'] ?? '';
$this->assertEquals(201, $execution['headers']['status-code']);
sleep(30);
$executions = $this->client->call(Client::METHOD_GET, '/functions/'.$functionId.'/executions', array_merge([
@ -653,6 +678,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals($stdout[4], $language);
$this->assertEquals($stdout[5], $version);
// $this->assertEquals($stdout[6], $fileId);
fwrite(STDERR, ".");
}
return [
@ -736,4 +762,4 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals($executions['body']['executions'][0]['stdout'], '');
$this->assertEquals($executions['body']['executions'][0]['stderr'], '');
}
}
}

Binary file not shown.

View file

@ -0,0 +1,26 @@
import "dart:io";
import "package:dart_appwrite/dart_appwrite.dart";
void main() { // Init SDK
Client client = Client();
client
.setEndpoint(Platform.environment["APPWRITE_ENDPOINT"]) // Your API Endpoint
.setProject(Platform.environment["APPWRITE_PROJECT"]) // Your project ID
.setKey(Platform.environment["APPWRITE_SECRET"]) // Your secret API key
;
Storage storage = Storage(client);
//Future result = storage.getFile(fileId: '[FILE_ID]');
print(Platform.environment["APPWRITE_FUNCTION_ID"]);
print(Platform.environment["APPWRITE_FUNCTION_NAME"]);
print(Platform.environment["APPWRITE_FUNCTION_TAG"]);
print(Platform.environment["APPWRITE_FUNCTION_TRIGGER"]);
print(Platform.environment["APPWRITE_FUNCTION_ENV_NAME"]);
print(Platform.environment["APPWRITE_FUNCTION_ENV_VERSION"]);
// print(result['$id']);
print(Platform.environment["APPWRITE_FUNCTION_EVENT"]);
print(Platform.environment["APPWRITE_FUNCTION_EVENT_PAYLOAD"]);
}

View file

@ -0,0 +1,7 @@
name: appwrite_cloud_function_demo
version: 0.1.0
description: Demo cloud function script.
environment:
sdk: '>=2.10.0 <3.0.0'
dependencies:
dart_appwrite: ^0.1.0

Binary file not shown.

View file

@ -0,0 +1,28 @@
using System;
using Appwrite;
namespace dotnet
{
class Program
{
static void Main(string[] args)
{
Client client = new Client();
client.SetEndPoint(Environment.GetEnvironmentVariable("APPWRITE_ENDPOINT"));
client.SetProject(Environment.GetEnvironmentVariable("APPWRITE_PROJECT"));
client.SetKey(Environment.GetEnvironmentVariable("APPWRITE_SECRET"));
Storage storage = new Storage(client);
Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_ID"));
Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_NAME"));
Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_TAG"));
Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_TRIGGER"));
Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_ENV_NAME"));
Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_ENV_VERSION"));
Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_EVENT"));
Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_EVENT_PAYLOAD"));
}
}
}

View file

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Appwrite" Version="0.0.3" />
</ItemGroup>
</Project>

Binary file not shown.

View file

@ -0,0 +1,28 @@
using System;
using Appwrite;
namespace dotnet
{
class Program
{
static void Main(string[] args)
{
Client client = new Client();
client.SetEndPoint(Environment.GetEnvironmentVariable("APPWRITE_ENDPOINT"));
client.SetProject(Environment.GetEnvironmentVariable("APPWRITE_PROJECT"));
client.SetKey(Environment.GetEnvironmentVariable("APPWRITE_SECRET"));
Storage storage = new Storage(client);
Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_ID"));
Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_NAME"));
Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_TAG"));
Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_TRIGGER"));
Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_ENV_NAME"));
Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_ENV_VERSION"));
Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_EVENT"));
Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_EVENT_PAYLOAD"));
}
}
}

View file

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Appwrite" Version="0.0.3" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,13 @@
echo 'Dart Packaging...'
cp -r $(pwd)/tests/resources/functions/dart $(pwd)/tests/resources/functions/packages/dart
docker run --rm -v $(pwd)/tests/resources/functions/packages/dart:/app -w /app appwrite/env-dart-2.10:1.0.0 ls
docker run --rm -v $(pwd)/tests/resources/functions/packages/dart:/app -w /app --env PUB_CACHE=./.appwrite appwrite/env-dart-2.10:1.0.0 pub get
docker run --rm -v $(pwd)/tests/resources/functions/packages/dart:/app -w /app appwrite/env-dart-2.10:1.0.0 tar -zcvf code.tar.gz .
mv $(pwd)/tests/resources/functions/packages/dart/code.tar.gz $(pwd)/tests/resources/functions/dart.tar.gz
rm -r $(pwd)/tests/resources/functions/packages/dart

View file

@ -0,0 +1,12 @@
echo '.NET 3.1 Packaging...'
cp -r $(pwd)/tests/resources/functions/dotnet-3.1 $(pwd)/tests/resources/functions/packages/dotnet-3.1
docker run --rm -v $(pwd)/tests/resources/functions/packages/dotnet-3.1:/app -w /app mcr.microsoft.com/dotnet/sdk:3.1-alpine dotnet restore
docker run --rm -v $(pwd)/tests/resources/functions/packages/dotnet-3.1:/app -w /app mcr.microsoft.com/dotnet/sdk:3.1-alpine dotnet publish -o ./release
docker run --rm -v $(pwd)/tests/resources/functions/packages/dotnet-3.1:/app -w /app/release appwrite/env-dotnet-3.1:1.0.0 tar -zcvf ../code.tar.gz .
mv $(pwd)/tests/resources/functions/packages/dotnet-3.1/code.tar.gz $(pwd)/tests/resources/functions/dotnet-3.1.tar.gz
rm -r $(pwd)/tests/resources/functions/packages/dotnet-3.1

View file

@ -0,0 +1,12 @@
echo '.NET 5.0 Packaging...'
cp -r $(pwd)/tests/resources/functions/dotnet-5.0 $(pwd)/tests/resources/functions/packages/dotnet-5.0
docker run --rm -v $(pwd)/tests/resources/functions/packages/dotnet-5.0:/app -w /app mcr.microsoft.com/dotnet/sdk:5.0-alpine dotnet restore
docker run --rm -v $(pwd)/tests/resources/functions/packages/dotnet-5.0:/app -w /app mcr.microsoft.com/dotnet/sdk:5.0-alpine dotnet publish -o ./release
docker run --rm -v $(pwd)/tests/resources/functions/packages/dotnet-5.0:/app -w /app/release appwrite/env-dotnet-5.0:1.0.0 tar -zcvf ../code.tar.gz .
mv $(pwd)/tests/resources/functions/packages/dotnet-5.0/code.tar.gz $(pwd)/tests/resources/functions/dotnet-5.0.tar.gz
rm -r $(pwd)/tests/resources/functions/packages/dotnet-5.0