├── .gitignore ├── README.md ├── cpp-17.0 ├── .gitignore ├── CMakeLists.txt ├── README.md └── src │ └── index.cc ├── dart-2.12 ├── .gitignore ├── README.md ├── analysis_options.yaml ├── lib │ └── main.dart └── pubspec.yaml ├── dart-2.13 ├── .gitignore ├── README.md ├── analysis_options.yaml ├── lib │ └── main.dart └── pubspec.yaml ├── dart-2.14 ├── .gitignore ├── README.md ├── analysis_options.yaml ├── lib │ └── main.dart └── pubspec.yaml ├── dart-2.15 ├── .gitignore ├── README.md ├── analysis_options.yaml ├── lib │ └── main.dart └── pubspec.yaml ├── dart-2.16 ├── .gitignore ├── README.md ├── analysis_options.yaml ├── lib │ └── main.dart └── pubspec.yaml ├── dart-2.17 ├── .gitignore ├── README.md ├── analysis_options.yaml ├── lib │ └── main.dart └── pubspec.yaml ├── dart-2.18 ├── .gitignore ├── README.md ├── analysis_options.yaml ├── lib │ └── main.dart └── pubspec.yaml ├── deno-1.12 ├── .gitignore ├── README.md └── src │ ├── deps.ts │ └── mod.ts ├── deno-1.13 ├── .gitignore ├── README.md └── src │ ├── deps.ts │ └── mod.ts ├── deno-1.14 ├── .DS_Store ├── .gitignore ├── README.md └── src │ ├── deps.ts │ └── mod.ts ├── deno-1.21 ├── .gitignore ├── README.md └── src │ ├── deps.ts │ └── mod.ts ├── deno-1.24 ├── .gitignore ├── README.md └── src │ ├── deps.ts │ └── mod.ts ├── dotnet-3.1 ├── .gitignore ├── Function.csproj ├── README.md └── src │ └── Index.cs ├── dotnet-6.0 ├── .gitignore ├── Function.csproj ├── README.md └── src │ └── Index.cs ├── java-11.0 ├── README.md ├── deps.gradle └── src │ └── Index.java ├── java-17.0 ├── README.md ├── deps.gradle └── src │ └── Index.java ├── java-18.0 ├── README.md ├── deps.gradle └── src │ └── Index.java ├── java-8.0 ├── README.md ├── deps.gradle └── src │ └── Index.java ├── kotlin-1.6 ├── README.md ├── deps.gradle └── src │ └── Index.kt ├── node-14.5 ├── .gitignore ├── README.md ├── package.json └── src │ └── index.js ├── node-15.5 ├── .gitignore ├── README.md ├── package.json └── src │ └── index.js ├── node-16.0 ├── .gitignore ├── README.md ├── package.json └── src │ └── index.js ├── node-17.0 ├── .gitignore ├── README.md ├── package.json └── src │ └── index.js ├── node-18.0 ├── .gitignore ├── README.md ├── package.json └── src │ └── index.js ├── php-8.0 ├── .gitignore ├── README.md ├── composer.json └── src │ └── index.php ├── php-8.1 ├── .gitignore ├── README.md ├── composer.json └── src │ └── index.php ├── python-3.10 ├── .gitignore ├── README.md ├── requirements.txt └── src │ └── index.py ├── python-3.8 ├── .gitignore ├── README.md ├── requirements.txt └── src │ └── index.py ├── python-3.9 ├── .gitignore ├── README.md ├── requirements.txt └── src │ └── index.py ├── ruby-3.0 ├── .gitignore ├── Gemfile ├── README.md └── src │ └── index.rb ├── ruby-3.1 ├── .gitignore ├── Gemfile ├── README.md └── src │ └── index.rb ├── rust-1.55 ├── .gitignore ├── README.md └── main.rs └── swift-5.5 ├── .gitignore ├── Package.swift ├── README.md └── Sources └── index.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # OS 2 | ## Mac 3 | .DS_Store 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Appwrite functions starter 2 | 3 | Templates for an [Open Runtimes](https://github.com/open-runtimes/open-runtimes) function that 4 | includes [Appwrite](https://github.com/appwrite/appwrite) library. These starters can be used by manually downloading 5 | the template in your favorite runtime (programming language), or by using AppwriteCLI: 6 | 7 | ```bash 8 | appwrite init function 9 | ``` 10 | 11 | ## Supported runtimes 12 | 13 | | Runtime | Versions | | | | | | 14 | |---------|----------|------|------|------|------|------| 15 | | C++ | 17.0 | | | | | | 16 | | Dart | 2.12 | 2.13 | 2.14 | 2.15 | 2.16 | 2.17 | 17 | | Deno | 1.12 | 1.13 | 1.14 | 1.21 | 1.24 | | 18 | | .NET | 3.1 | 6.0 | | | | | 19 | | Java | 8.0 | 11.0 | 17.0 | 18.0 | | | 20 | | Kotlin | 1.6 | | | | | | 21 | | Node | 14.5 | 15.5 | 16.0 | 17.0 | 18.0 | | 22 | | PHP | 8.0 | 8.1 | | | | | 23 | | Python | 3.8 | 3.9 | 3.10 | | | | 24 | | Ruby | 3.0 | 3.1 | | | | | 25 | | Rust | 1.55 | | | | | | 26 | | Swift | 5.5 | | | | | | 27 | -------------------------------------------------------------------------------- /cpp-17.0/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app -------------------------------------------------------------------------------- /cpp-17.0/CMakeLists.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appwrite/functions-starter/81fc07af5a0d8efacc8e508fe7337b433b80eb6f/cpp-17.0/CMakeLists.txt -------------------------------------------------------------------------------- /cpp-17.0/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | This cloud function does not need any environment variables by default. 32 | 33 | 34 | ## 🚀 Deployment 35 | 36 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 37 | 38 | ### Using CLI 39 | 40 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 41 | 42 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 43 | 44 | ### Manual using tar.gz 45 | 46 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/index.cc`, and upload the file we just generated. 47 | -------------------------------------------------------------------------------- /cpp-17.0/src/index.cc: -------------------------------------------------------------------------------- 1 | /* 2 | 'req' variable has: 3 | 'headers' - object with request headers 4 | 'payload' - request body data as a string 5 | 'variables' - object with function variables 6 | 'res' variable has: 7 | 'send(text, status)' - function to return text response. Status code defaults to 200 8 | 'json(obj, status)' - function to return JSON response. Status code defaults to 200 9 | 10 | If an error is thrown, a response with code 500 will be returned. 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | static RuntimeResponse &main(const RuntimeRequest &req, RuntimeResponse &res) { 17 | 18 | // Appwrite's SDK for C++ is currently under the works and shall be available soon 19 | 20 | Json::Value response; 21 | response["areDevelopersAwesome"] = true; 22 | 23 | return res.json(response); 24 | } 25 | -------------------------------------------------------------------------------- /dart-2.12/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/dart 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=dart 4 | 5 | ### Dart ### 6 | # See https://www.dartlang.org/guides/libraries/private-files 7 | 8 | # Files and directories created by pub 9 | .dart_tool/ 10 | .packages 11 | build/ 12 | # If you're building an application, you may want to check-in your pubspec.lock 13 | pubspec.lock 14 | 15 | # Directory created by dartdoc 16 | # If you don't generate documentation locally you can remove this line. 17 | doc/api/ 18 | 19 | # dotenv environment variables file 20 | .env* 21 | 22 | # Avoid committing generated Javascript files: 23 | *.dart.js 24 | *.info.json # Produced by the --dump-info flag. 25 | *.js # When generated by dart2js. Don't specify *.js if your 26 | # project includes source files written in JavaScript. 27 | *.js_ 28 | *.js.deps 29 | *.js.map 30 | 31 | .flutter-plugins 32 | .flutter-plugins-dependencies 33 | 34 | ### Dart Patch ### 35 | # dotenv environment variables file 36 | .env 37 | 38 | # End of https://www.toptal.com/developers/gitignore/api/dart 39 | 40 | # OS 41 | ## Mac 42 | .DS_Store 43 | -------------------------------------------------------------------------------- /dart-2.12/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `lib/main.dart`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /dart-2.12/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:lints/recommended.yaml 2 | -------------------------------------------------------------------------------- /dart-2.12/lib/main.dart: -------------------------------------------------------------------------------- 1 | /* 2 | 'req' variable has: 3 | 'headers' - object with request headers 4 | 'payload' - request body data as a string 5 | 'variables' - object with function variables 6 | 7 | 'res' variable has: 8 | 'send(text, status: status)' - function to return text response. Status code defaults to 200 9 | 'json(obj, status: status)' - function to return JSON response. Status code defaults to 200 10 | 11 | If an error is thrown, a response with code 500 will be returned. 12 | */ 13 | 14 | Future start(final req, final res) async { 15 | // Appwrite SDK is not supported in this version. Please use dart-2.14 or above if you need Appwrite SDK. 16 | 17 | res.json({ 18 | 'areDevelopersAwesome': true, 19 | }); 20 | } -------------------------------------------------------------------------------- /dart-2.12/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: appwrite_function 2 | description: Dart starter for Appwrite function. 3 | version: 1.0.0 4 | publish_to: 'none' 5 | 6 | environment: 7 | sdk: '>=2.12.0 <3.0.0' 8 | 9 | dev_dependencies: 10 | lints: ^1.0.1 11 | -------------------------------------------------------------------------------- /dart-2.13/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/dart 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=dart 4 | 5 | ### Dart ### 6 | # See https://www.dartlang.org/guides/libraries/private-files 7 | 8 | # Files and directories created by pub 9 | .dart_tool/ 10 | .packages 11 | build/ 12 | # If you're building an application, you may want to check-in your pubspec.lock 13 | pubspec.lock 14 | 15 | # Directory created by dartdoc 16 | # If you don't generate documentation locally you can remove this line. 17 | doc/api/ 18 | 19 | # dotenv environment variables file 20 | .env* 21 | 22 | # Avoid committing generated Javascript files: 23 | *.dart.js 24 | *.info.json # Produced by the --dump-info flag. 25 | *.js # When generated by dart2js. Don't specify *.js if your 26 | # project includes source files written in JavaScript. 27 | *.js_ 28 | *.js.deps 29 | *.js.map 30 | 31 | .flutter-plugins 32 | .flutter-plugins-dependencies 33 | 34 | ### Dart Patch ### 35 | # dotenv environment variables file 36 | .env 37 | 38 | # End of https://www.toptal.com/developers/gitignore/api/dart 39 | 40 | # OS 41 | ## Mac 42 | .DS_Store 43 | -------------------------------------------------------------------------------- /dart-2.13/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `lib/main.dart`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /dart-2.13/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:lints/recommended.yaml 2 | -------------------------------------------------------------------------------- /dart-2.13/lib/main.dart: -------------------------------------------------------------------------------- 1 | /* 2 | 'req' variable has: 3 | 'headers' - object with request headers 4 | 'payload' - request body data as a string 5 | 'variables' - object with function variables 6 | 7 | 'res' variable has: 8 | 'send(text, status: status)' - function to return text response. Status code defaults to 200 9 | 'json(obj, status: status)' - function to return JSON response. Status code defaults to 200 10 | 11 | If an error is thrown, a response with code 500 will be returned. 12 | */ 13 | 14 | Future start(final req, final res) async { 15 | // Appwrite SDK is not supported in this version. Please use dart-2.14 or above if you need Appwrite SDK. 16 | 17 | res.json({ 18 | 'areDevelopersAwesome': true, 19 | }); 20 | } -------------------------------------------------------------------------------- /dart-2.13/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: appwrite_function 2 | description: Dart starter for Appwrite function. 3 | version: 1.0.0 4 | publish_to: 'none' 5 | 6 | environment: 7 | sdk: '>=2.13.0 <3.0.0' 8 | 9 | dev_dependencies: 10 | lints: ^1.0.1 11 | -------------------------------------------------------------------------------- /dart-2.14/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/dart 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=dart 4 | 5 | ### Dart ### 6 | # See https://www.dartlang.org/guides/libraries/private-files 7 | 8 | # Files and directories created by pub 9 | .dart_tool/ 10 | .packages 11 | build/ 12 | # If you're building an application, you may want to check-in your pubspec.lock 13 | pubspec.lock 14 | 15 | # Directory created by dartdoc 16 | # If you don't generate documentation locally you can remove this line. 17 | doc/api/ 18 | 19 | # dotenv environment variables file 20 | .env* 21 | 22 | # Avoid committing generated Javascript files: 23 | *.dart.js 24 | *.info.json # Produced by the --dump-info flag. 25 | *.js # When generated by dart2js. Don't specify *.js if your 26 | # project includes source files written in JavaScript. 27 | *.js_ 28 | *.js.deps 29 | *.js.map 30 | 31 | .flutter-plugins 32 | .flutter-plugins-dependencies 33 | 34 | ### Dart Patch ### 35 | # dotenv environment variables file 36 | .env 37 | 38 | # End of https://www.toptal.com/developers/gitignore/api/dart 39 | 40 | # OS 41 | ## Mac 42 | .DS_Store 43 | -------------------------------------------------------------------------------- /dart-2.14/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `lib/main.dart`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /dart-2.14/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:lints/recommended.yaml 2 | -------------------------------------------------------------------------------- /dart-2.14/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:dart_appwrite/dart_appwrite.dart'; 2 | 3 | /* 4 | 'req' variable has: 5 | 'headers' - object with request headers 6 | 'payload' - request body data as a string 7 | 'variables' - object with function variables 8 | 9 | 'res' variable has: 10 | 'send(text, status: status)' - function to return text response. Status code defaults to 200 11 | 'json(obj, status: status)' - function to return JSON response. Status code defaults to 200 12 | 13 | If an error is thrown, a response with code 500 will be returned. 14 | */ 15 | 16 | Future start(final req, final res) async { 17 | final client = Client(); 18 | 19 | // Uncomment the services you need, delete the ones you don't 20 | // final account = Account(client); 21 | // final avatars = Avatars(client); 22 | // final database = Databases(client); 23 | // final functions = Functions(client); 24 | // final health = Health(client); 25 | // final locale = Locale(client); 26 | // final storage = Storage(client); 27 | // final teams = Teams(client); 28 | // final users = Users(client); 29 | 30 | if (req.variables['APPWRITE_FUNCTION_ENDPOINT'] == null || 31 | req.variables['APPWRITE_FUNCTION_API_KEY'] == null) { 32 | print( 33 | "Environment variables are not set. Function cannot use Appwrite SDK."); 34 | } else { 35 | client 36 | .setEndpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT']) 37 | .setProject(req.variables['APPWRITE_FUNCTION_PROJECT_ID']) 38 | .setKey(req.variables['APPWRITE_FUNCTION_API_KEY']) 39 | .setSelfSigned(status: true); 40 | } 41 | 42 | res.json({ 43 | 'areDevelopersAwesome': true, 44 | }); 45 | } 46 | -------------------------------------------------------------------------------- /dart-2.14/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: appwrite_function 2 | description: Dart starter for Appwrite function. 3 | version: 1.0.0 4 | publish_to: 'none' 5 | 6 | environment: 7 | sdk: '>=2.14.0 <3.0.0' 8 | 9 | dependencies: 10 | dart_appwrite: ^7.1.0 11 | 12 | dev_dependencies: 13 | lints: ^1.0.1 14 | -------------------------------------------------------------------------------- /dart-2.15/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/dart 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=dart 4 | 5 | ### Dart ### 6 | # See https://www.dartlang.org/guides/libraries/private-files 7 | 8 | # Files and directories created by pub 9 | .dart_tool/ 10 | .packages 11 | build/ 12 | # If you're building an application, you may want to check-in your pubspec.lock 13 | pubspec.lock 14 | 15 | # Directory created by dartdoc 16 | # If you don't generate documentation locally you can remove this line. 17 | doc/api/ 18 | 19 | # dotenv environment variables file 20 | .env* 21 | 22 | # Avoid committing generated Javascript files: 23 | *.dart.js 24 | *.info.json # Produced by the --dump-info flag. 25 | *.js # When generated by dart2js. Don't specify *.js if your 26 | # project includes source files written in JavaScript. 27 | *.js_ 28 | *.js.deps 29 | *.js.map 30 | 31 | .flutter-plugins 32 | .flutter-plugins-dependencies 33 | 34 | ### Dart Patch ### 35 | # dotenv environment variables file 36 | .env 37 | 38 | # End of https://www.toptal.com/developers/gitignore/api/dart 39 | 40 | # OS 41 | ## Mac 42 | .DS_Store 43 | -------------------------------------------------------------------------------- /dart-2.15/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `lib/main.dart`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /dart-2.15/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:lints/recommended.yaml 2 | -------------------------------------------------------------------------------- /dart-2.15/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:dart_appwrite/dart_appwrite.dart'; 2 | 3 | /* 4 | 'req' variable has: 5 | 'headers' - object with request headers 6 | 'payload' - request body data as a string 7 | 'variables' - object with function variables 8 | 9 | 'res' variable has: 10 | 'send(text, status: status)' - function to return text response. Status code defaults to 200 11 | 'json(obj, status: status)' - function to return JSON response. Status code defaults to 200 12 | 13 | If an error is thrown, a response with code 500 will be returned. 14 | */ 15 | 16 | Future start(final req, final res) async { 17 | final client = Client(); 18 | 19 | // Uncomment the services you need, delete the ones you don't 20 | // final account = Account(client); 21 | // final avatars = Avatars(client); 22 | // final database = Databases(client); 23 | // final functions = Functions(client); 24 | // final health = Health(client); 25 | // final locale = Locale(client); 26 | // final storage = Storage(client); 27 | // final teams = Teams(client); 28 | // final users = Users(client); 29 | 30 | if (req.variables['APPWRITE_FUNCTION_ENDPOINT'] == null || 31 | req.variables['APPWRITE_FUNCTION_API_KEY'] == null) { 32 | print( 33 | "Environment variables are not set. Function cannot use Appwrite SDK."); 34 | } else { 35 | client 36 | .setEndpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT']) 37 | .setProject(req.variables['APPWRITE_FUNCTION_PROJECT_ID']) 38 | .setKey(req.variables['APPWRITE_FUNCTION_API_KEY']) 39 | .setSelfSigned(status: true); 40 | } 41 | 42 | res.json({ 43 | 'areDevelopersAwesome': true, 44 | }); 45 | } 46 | -------------------------------------------------------------------------------- /dart-2.15/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: appwrite_function 2 | description: Dart starter for Appwrite function. 3 | version: 1.0.0 4 | publish_to: 'none' 5 | 6 | environment: 7 | sdk: '>=2.15.0 <3.0.0' 8 | 9 | dependencies: 10 | dart_appwrite: ^7.1.0 11 | 12 | dev_dependencies: 13 | lints: ^1.0.1 14 | -------------------------------------------------------------------------------- /dart-2.16/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/dart 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=dart 4 | 5 | ### Dart ### 6 | # See https://www.dartlang.org/guides/libraries/private-files 7 | 8 | # Files and directories created by pub 9 | .dart_tool/ 10 | .packages 11 | build/ 12 | # If you're building an application, you may want to check-in your pubspec.lock 13 | pubspec.lock 14 | 15 | # Directory created by dartdoc 16 | # If you don't generate documentation locally you can remove this line. 17 | doc/api/ 18 | 19 | # dotenv environment variables file 20 | .env* 21 | 22 | # Avoid committing generated Javascript files: 23 | *.dart.js 24 | *.info.json # Produced by the --dump-info flag. 25 | *.js # When generated by dart2js. Don't specify *.js if your 26 | # project includes source files written in JavaScript. 27 | *.js_ 28 | *.js.deps 29 | *.js.map 30 | 31 | .flutter-plugins 32 | .flutter-plugins-dependencies 33 | 34 | ### Dart Patch ### 35 | # dotenv environment variables file 36 | .env 37 | 38 | # End of https://www.toptal.com/developers/gitignore/api/dart 39 | 40 | # OS 41 | ## Mac 42 | .DS_Store 43 | -------------------------------------------------------------------------------- /dart-2.16/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `lib/main.dart`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /dart-2.16/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:lints/recommended.yaml 2 | -------------------------------------------------------------------------------- /dart-2.16/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:dart_appwrite/dart_appwrite.dart'; 2 | 3 | /* 4 | 'req' variable has: 5 | 'headers' - object with request headers 6 | 'payload' - request body data as a string 7 | 'variables' - object with function variables 8 | 9 | 'res' variable has: 10 | 'send(text, status: status)' - function to return text response. Status code defaults to 200 11 | 'json(obj, status: status)' - function to return JSON response. Status code defaults to 200 12 | 13 | If an error is thrown, a response with code 500 will be returned. 14 | */ 15 | 16 | Future start(final req, final res) async { 17 | final client = Client(); 18 | 19 | // Uncomment the services you need, delete the ones you don't 20 | // final account = Account(client); 21 | // final avatars = Avatars(client); 22 | // final database = Databases(client); 23 | // final functions = Functions(client); 24 | // final health = Health(client); 25 | // final locale = Locale(client); 26 | // final storage = Storage(client); 27 | // final teams = Teams(client); 28 | // final users = Users(client); 29 | 30 | if (req.variables['APPWRITE_FUNCTION_ENDPOINT'] == null || 31 | req.variables['APPWRITE_FUNCTION_API_KEY'] == null) { 32 | print( 33 | "Environment variables are not set. Function cannot use Appwrite SDK."); 34 | } else { 35 | client 36 | .setEndpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT']) 37 | .setProject(req.variables['APPWRITE_FUNCTION_PROJECT_ID']) 38 | .setKey(req.variables['APPWRITE_FUNCTION_API_KEY']) 39 | .setSelfSigned(status: true); 40 | } 41 | 42 | res.json({ 43 | 'areDevelopersAwesome': true, 44 | }); 45 | } 46 | -------------------------------------------------------------------------------- /dart-2.16/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: appwrite_function 2 | description: Dart starter for Appwrite function. 3 | version: 1.0.0 4 | publish_to: 'none' 5 | 6 | environment: 7 | sdk: '>=2.16.0 <3.0.0' 8 | 9 | dependencies: 10 | dart_appwrite: ^7.1.0 11 | 12 | dev_dependencies: 13 | lints: ^1.0.1 14 | -------------------------------------------------------------------------------- /dart-2.17/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/dart 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=dart 4 | 5 | ### Dart ### 6 | # See https://www.dartlang.org/guides/libraries/private-files 7 | 8 | # Files and directories created by pub 9 | .dart_tool/ 10 | .packages 11 | build/ 12 | # If you're building an application, you may want to check-in your pubspec.lock 13 | pubspec.lock 14 | 15 | # Directory created by dartdoc 16 | # If you don't generate documentation locally you can remove this line. 17 | doc/api/ 18 | 19 | # dotenv environment variables file 20 | .env* 21 | 22 | # Avoid committing generated Javascript files: 23 | *.dart.js 24 | *.info.json # Produced by the --dump-info flag. 25 | *.js # When generated by dart2js. Don't specify *.js if your 26 | # project includes source files written in JavaScript. 27 | *.js_ 28 | *.js.deps 29 | *.js.map 30 | 31 | .flutter-plugins 32 | .flutter-plugins-dependencies 33 | 34 | ### Dart Patch ### 35 | # dotenv environment variables file 36 | .env 37 | 38 | # End of https://www.toptal.com/developers/gitignore/api/dart 39 | 40 | # OS 41 | ## Mac 42 | .DS_Store 43 | -------------------------------------------------------------------------------- /dart-2.17/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `lib/main.dart`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /dart-2.17/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:lints/recommended.yaml 2 | -------------------------------------------------------------------------------- /dart-2.17/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:dart_appwrite/dart_appwrite.dart'; 2 | 3 | /* 4 | 'req' variable has: 5 | 'headers' - object with request headers 6 | 'payload' - request body data as a string 7 | 'variables' - object with function variables 8 | 9 | 'res' variable has: 10 | 'send(text, status: status)' - function to return text response. Status code defaults to 200 11 | 'json(obj, status: status)' - function to return JSON response. Status code defaults to 200 12 | 13 | If an error is thrown, a response with code 500 will be returned. 14 | */ 15 | 16 | Future start(final req, final res) async { 17 | final client = Client(); 18 | 19 | // Uncomment the services you need, delete the ones you don't 20 | // final account = Account(client); 21 | // final avatars = Avatars(client); 22 | // final database = Databases(client); 23 | // final functions = Functions(client); 24 | // final health = Health(client); 25 | // final locale = Locale(client); 26 | // final storage = Storage(client); 27 | // final teams = Teams(client); 28 | // final users = Users(client); 29 | 30 | if (req.variables['APPWRITE_FUNCTION_ENDPOINT'] == null || 31 | req.variables['APPWRITE_FUNCTION_API_KEY'] == null) { 32 | print( 33 | "Environment variables are not set. Function cannot use Appwrite SDK."); 34 | } else { 35 | client 36 | .setEndpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT']) 37 | .setProject(req.variables['APPWRITE_FUNCTION_PROJECT_ID']) 38 | .setKey(req.variables['APPWRITE_FUNCTION_API_KEY']) 39 | .setSelfSigned(status: true); 40 | } 41 | 42 | res.json({ 43 | 'areDevelopersAwesome': true, 44 | }); 45 | } 46 | -------------------------------------------------------------------------------- /dart-2.17/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: appwrite_function 2 | description: Dart starter for Appwrite function. 3 | version: 1.0.0 4 | publish_to: 'none' 5 | 6 | environment: 7 | sdk: '>=2.17.0 <3.0.0' 8 | 9 | dependencies: 10 | dart_appwrite: ^7.1.0 11 | 12 | dev_dependencies: 13 | lints: ^2.0.1 14 | -------------------------------------------------------------------------------- /dart-2.18/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/dart 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=dart 4 | 5 | ### Dart ### 6 | # See https://www.dartlang.org/guides/libraries/private-files 7 | 8 | # Files and directories created by pub 9 | .dart_tool/ 10 | .packages 11 | build/ 12 | # If you're building an application, you may want to check-in your pubspec.lock 13 | pubspec.lock 14 | 15 | # Directory created by dartdoc 16 | # If you don't generate documentation locally you can remove this line. 17 | doc/api/ 18 | 19 | # dotenv environment variables file 20 | .env* 21 | 22 | # Avoid committing generated Javascript files: 23 | *.dart.js 24 | *.info.json # Produced by the --dump-info flag. 25 | *.js # When generated by dart2js. Don't specify *.js if your 26 | # project includes source files written in JavaScript. 27 | *.js_ 28 | *.js.deps 29 | *.js.map 30 | 31 | .flutter-plugins 32 | .flutter-plugins-dependencies 33 | 34 | ### Dart Patch ### 35 | # dotenv environment variables file 36 | .env 37 | 38 | # End of https://www.toptal.com/developers/gitignore/api/dart 39 | 40 | # OS 41 | ## Mac 42 | .DS_Store 43 | -------------------------------------------------------------------------------- /dart-2.18/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `lib/main.dart`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /dart-2.18/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:lints/recommended.yaml 2 | -------------------------------------------------------------------------------- /dart-2.18/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:dart_appwrite/dart_appwrite.dart'; 2 | 3 | /* 4 | 'req' variable has: 5 | 'headers' - object with request headers 6 | 'payload' - request body data as a string 7 | 'variables' - object with function variables 8 | 9 | 'res' variable has: 10 | 'send(text, status: status)' - function to return text response. Status code defaults to 200 11 | 'json(obj, status: status)' - function to return JSON response. Status code defaults to 200 12 | 13 | If an error is thrown, a response with code 500 will be returned. 14 | */ 15 | 16 | Future start(final req, final res) async { 17 | final client = Client(); 18 | 19 | // Uncomment the services you need, delete the ones you don't 20 | // final account = Account(client); 21 | // final avatars = Avatars(client); 22 | // final database = Databases(client); 23 | // final functions = Functions(client); 24 | // final health = Health(client); 25 | // final locale = Locale(client); 26 | // final storage = Storage(client); 27 | // final teams = Teams(client); 28 | // final users = Users(client); 29 | 30 | if (req.variables['APPWRITE_FUNCTION_ENDPOINT'] == null || 31 | req.variables['APPWRITE_FUNCTION_API_KEY'] == null) { 32 | print( 33 | "Environment variables are not set. Function cannot use Appwrite SDK."); 34 | } else { 35 | client 36 | .setEndpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT']) 37 | .setProject(req.variables['APPWRITE_FUNCTION_PROJECT_ID']) 38 | .setKey(req.variables['APPWRITE_FUNCTION_API_KEY']) 39 | .setSelfSigned(status: true); 40 | } 41 | 42 | res.json({ 43 | 'areDevelopersAwesome': true, 44 | }); 45 | } 46 | -------------------------------------------------------------------------------- /dart-2.18/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: appwrite_function 2 | description: Dart starter for Appwrite function. 3 | version: 1.0.0 4 | publish_to: 'none' 5 | 6 | environment: 7 | sdk: '>=2.18.0 <3.0.0' 8 | 9 | dependencies: 10 | dart_appwrite: ^7.1.0 11 | 12 | dev_dependencies: 13 | lints: ^2.0.1 14 | -------------------------------------------------------------------------------- /deno-1.12/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/node 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=node 4 | 5 | ### Node ### 6 | # Logs 7 | logs 8 | *.log 9 | npm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | lerna-debug.log* 13 | .pnpm-debug.log* 14 | 15 | # Diagnostic reports (https://nodejs.org/api/report.html) 16 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | *.pid.lock 23 | 24 | # Directory for instrumented libs generated by jscoverage/JSCover 25 | lib-cov 26 | 27 | # Coverage directory used by tools like istanbul 28 | coverage 29 | *.lcov 30 | 31 | # nyc test coverage 32 | .nyc_output 33 | 34 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 35 | .grunt 36 | 37 | # Bower dependency directory (https://bower.io/) 38 | bower_components 39 | 40 | # node-waf configuration 41 | .lock-wscript 42 | 43 | # Compiled binary addons (https://nodejs.org/api/addons.html) 44 | build/Release 45 | 46 | # Dependency directories 47 | node_modules/ 48 | jspm_packages/ 49 | 50 | # Snowpack dependency directory (https://snowpack.dev/) 51 | web_modules/ 52 | 53 | # TypeScript cache 54 | *.tsbuildinfo 55 | 56 | # Optional npm cache directory 57 | .npm 58 | 59 | # Optional eslint cache 60 | .eslintcache 61 | 62 | # Optional stylelint cache 63 | .stylelintcache 64 | 65 | # Microbundle cache 66 | .rpt2_cache/ 67 | .rts2_cache_cjs/ 68 | .rts2_cache_es/ 69 | .rts2_cache_umd/ 70 | 71 | # Optional REPL history 72 | .node_repl_history 73 | 74 | # Output of 'npm pack' 75 | *.tgz 76 | 77 | # Yarn Integrity file 78 | .yarn-integrity 79 | 80 | # dotenv environment variable files 81 | .env 82 | .env.development.local 83 | .env.test.local 84 | .env.production.local 85 | .env.local 86 | 87 | # parcel-bundler cache (https://parceljs.org/) 88 | .cache 89 | .parcel-cache 90 | 91 | # Next.js build output 92 | .next 93 | out 94 | 95 | # Nuxt.js build / generate output 96 | .nuxt 97 | dist 98 | 99 | # Gatsby files 100 | .cache/ 101 | # Comment in the public line in if your project uses Gatsby and not Next.js 102 | # https://nextjs.org/blog/next-9-1#public-directory-support 103 | # public 104 | 105 | # vuepress build output 106 | .vuepress/dist 107 | 108 | # vuepress v2.x temp and cache directory 109 | .temp 110 | 111 | # Docusaurus cache and generated files 112 | .docusaurus 113 | 114 | # Serverless directories 115 | .serverless/ 116 | 117 | # FuseBox cache 118 | .fusebox/ 119 | 120 | # DynamoDB Local files 121 | .dynamodb/ 122 | 123 | # TernJS port file 124 | .tern-port 125 | 126 | # Stores VSCode versions used for testing VSCode extensions 127 | .vscode-test 128 | 129 | # yarn v2 130 | .yarn/cache 131 | .yarn/unplugged 132 | .yarn/build-state.yml 133 | .yarn/install-state.gz 134 | .pnp.* 135 | 136 | ### Node Patch ### 137 | # Serverless Webpack directories 138 | .webpack/ 139 | 140 | # Optional stylelint cache 141 | 142 | # SvelteKit build / generate output 143 | .svelte-kit 144 | 145 | # End of https://www.toptal.com/developers/gitignore/api/node 146 | 147 | # OS 148 | ## Mac 149 | .DS_Store 150 | -------------------------------------------------------------------------------- /deno-1.12/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/mod.ts`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /deno-1.12/src/deps.ts: -------------------------------------------------------------------------------- 1 | export * as sdk from "https://deno.land/x/appwrite@6.0.0/mod.ts"; 2 | -------------------------------------------------------------------------------- /deno-1.12/src/mod.ts: -------------------------------------------------------------------------------- 1 | import { sdk } from "./deps.ts"; 2 | 3 | /* 4 | 'req' variable has: 5 | 'headers' - object with request headers 6 | 'payload' - request body data as a string 7 | 'variables' - object with function variables 8 | 9 | 'res' variable has: 10 | 'send(text, status)' - function to return text response. Status code defaults to 200 11 | 'json(obj, status)' - function to return JSON response. Status code defaults to 200 12 | 13 | If an error is thrown, a response with code 500 will be returned. 14 | */ 15 | 16 | export default async function (req: any, res: any) { 17 | const client = new sdk.Client(); 18 | 19 | // You can remove services you don't use 20 | const account = new sdk.Account(client); 21 | const avatars = new sdk.Avatars(client); 22 | const database = new sdk.Databases(client); 23 | const functions = new sdk.Functions(client); 24 | const health = new sdk.Health(client); 25 | const locale = new sdk.Locale(client); 26 | const storage = new sdk.Storage(client); 27 | const teams = new sdk.Teams(client); 28 | const users = new sdk.Users(client); 29 | 30 | if (!req.variables['APPWRITE_FUNCTION_ENDPOINT'] || !req.variables['APPWRITE_FUNCTION_API_KEY']) { 31 | console.warn("Environment variables are not set. Function cannot use Appwrite SDK."); 32 | } else { 33 | client 34 | .setEndpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT'] as string) 35 | .setProject(req.variables['APPWRITE_FUNCTION_PROJECT_ID'] as string) 36 | .setKey(req.variables['APPWRITE_FUNCTION_API_KEY'] as string); 37 | } 38 | 39 | res.json({ 40 | areDevelopersAwesome: true, 41 | }); 42 | } -------------------------------------------------------------------------------- /deno-1.13/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/node 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=node 4 | 5 | ### Node ### 6 | # Logs 7 | logs 8 | *.log 9 | npm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | lerna-debug.log* 13 | .pnpm-debug.log* 14 | 15 | # Diagnostic reports (https://nodejs.org/api/report.html) 16 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | *.pid.lock 23 | 24 | # Directory for instrumented libs generated by jscoverage/JSCover 25 | lib-cov 26 | 27 | # Coverage directory used by tools like istanbul 28 | coverage 29 | *.lcov 30 | 31 | # nyc test coverage 32 | .nyc_output 33 | 34 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 35 | .grunt 36 | 37 | # Bower dependency directory (https://bower.io/) 38 | bower_components 39 | 40 | # node-waf configuration 41 | .lock-wscript 42 | 43 | # Compiled binary addons (https://nodejs.org/api/addons.html) 44 | build/Release 45 | 46 | # Dependency directories 47 | node_modules/ 48 | jspm_packages/ 49 | 50 | # Snowpack dependency directory (https://snowpack.dev/) 51 | web_modules/ 52 | 53 | # TypeScript cache 54 | *.tsbuildinfo 55 | 56 | # Optional npm cache directory 57 | .npm 58 | 59 | # Optional eslint cache 60 | .eslintcache 61 | 62 | # Optional stylelint cache 63 | .stylelintcache 64 | 65 | # Microbundle cache 66 | .rpt2_cache/ 67 | .rts2_cache_cjs/ 68 | .rts2_cache_es/ 69 | .rts2_cache_umd/ 70 | 71 | # Optional REPL history 72 | .node_repl_history 73 | 74 | # Output of 'npm pack' 75 | *.tgz 76 | 77 | # Yarn Integrity file 78 | .yarn-integrity 79 | 80 | # dotenv environment variable files 81 | .env 82 | .env.development.local 83 | .env.test.local 84 | .env.production.local 85 | .env.local 86 | 87 | # parcel-bundler cache (https://parceljs.org/) 88 | .cache 89 | .parcel-cache 90 | 91 | # Next.js build output 92 | .next 93 | out 94 | 95 | # Nuxt.js build / generate output 96 | .nuxt 97 | dist 98 | 99 | # Gatsby files 100 | .cache/ 101 | # Comment in the public line in if your project uses Gatsby and not Next.js 102 | # https://nextjs.org/blog/next-9-1#public-directory-support 103 | # public 104 | 105 | # vuepress build output 106 | .vuepress/dist 107 | 108 | # vuepress v2.x temp and cache directory 109 | .temp 110 | 111 | # Docusaurus cache and generated files 112 | .docusaurus 113 | 114 | # Serverless directories 115 | .serverless/ 116 | 117 | # FuseBox cache 118 | .fusebox/ 119 | 120 | # DynamoDB Local files 121 | .dynamodb/ 122 | 123 | # TernJS port file 124 | .tern-port 125 | 126 | # Stores VSCode versions used for testing VSCode extensions 127 | .vscode-test 128 | 129 | # yarn v2 130 | .yarn/cache 131 | .yarn/unplugged 132 | .yarn/build-state.yml 133 | .yarn/install-state.gz 134 | .pnp.* 135 | 136 | ### Node Patch ### 137 | # Serverless Webpack directories 138 | .webpack/ 139 | 140 | # Optional stylelint cache 141 | 142 | # SvelteKit build / generate output 143 | .svelte-kit 144 | 145 | # End of https://www.toptal.com/developers/gitignore/api/node 146 | 147 | # OS 148 | ## Mac 149 | .DS_Store 150 | -------------------------------------------------------------------------------- /deno-1.13/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/mod.ts`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /deno-1.13/src/deps.ts: -------------------------------------------------------------------------------- 1 | export * as sdk from "https://deno.land/x/appwrite@6.0.0/mod.ts"; 2 | -------------------------------------------------------------------------------- /deno-1.13/src/mod.ts: -------------------------------------------------------------------------------- 1 | import { sdk } from "./deps.ts"; 2 | 3 | /* 4 | 'req' variable has: 5 | 'headers' - object with request headers 6 | 'payload' - request body data as a string 7 | 'variables' - object with function variables 8 | 9 | 'res' variable has: 10 | 'send(text, status)' - function to return text response. Status code defaults to 200 11 | 'json(obj, status)' - function to return JSON response. Status code defaults to 200 12 | 13 | If an error is thrown, a response with code 500 will be returned. 14 | */ 15 | 16 | export default async function (req: any, res: any) { 17 | const client = new sdk.Client(); 18 | 19 | // You can remove services you don't use 20 | const account = new sdk.Account(client); 21 | const avatars = new sdk.Avatars(client); 22 | const database = new sdk.Databases(client); 23 | const functions = new sdk.Functions(client); 24 | const health = new sdk.Health(client); 25 | const locale = new sdk.Locale(client); 26 | const storage = new sdk.Storage(client); 27 | const teams = new sdk.Teams(client); 28 | const users = new sdk.Users(client); 29 | 30 | if (!req.variables['APPWRITE_FUNCTION_ENDPOINT'] || !req.variables['APPWRITE_FUNCTION_API_KEY']) { 31 | console.warn("Environment variables are not set. Function cannot use Appwrite SDK."); 32 | } else { 33 | client 34 | .setEndpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT'] as string) 35 | .setProject(req.variables['APPWRITE_FUNCTION_PROJECT_ID'] as string) 36 | .setKey(req.variables['APPWRITE_FUNCTION_API_KEY'] as string); 37 | } 38 | 39 | res.json({ 40 | areDevelopersAwesome: true, 41 | }); 42 | } -------------------------------------------------------------------------------- /deno-1.14/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appwrite/functions-starter/81fc07af5a0d8efacc8e508fe7337b433b80eb6f/deno-1.14/.DS_Store -------------------------------------------------------------------------------- /deno-1.14/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/node 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=node 4 | 5 | ### Node ### 6 | # Logs 7 | logs 8 | *.log 9 | npm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | lerna-debug.log* 13 | .pnpm-debug.log* 14 | 15 | # Diagnostic reports (https://nodejs.org/api/report.html) 16 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | *.pid.lock 23 | 24 | # Directory for instrumented libs generated by jscoverage/JSCover 25 | lib-cov 26 | 27 | # Coverage directory used by tools like istanbul 28 | coverage 29 | *.lcov 30 | 31 | # nyc test coverage 32 | .nyc_output 33 | 34 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 35 | .grunt 36 | 37 | # Bower dependency directory (https://bower.io/) 38 | bower_components 39 | 40 | # node-waf configuration 41 | .lock-wscript 42 | 43 | # Compiled binary addons (https://nodejs.org/api/addons.html) 44 | build/Release 45 | 46 | # Dependency directories 47 | node_modules/ 48 | jspm_packages/ 49 | 50 | # Snowpack dependency directory (https://snowpack.dev/) 51 | web_modules/ 52 | 53 | # TypeScript cache 54 | *.tsbuildinfo 55 | 56 | # Optional npm cache directory 57 | .npm 58 | 59 | # Optional eslint cache 60 | .eslintcache 61 | 62 | # Optional stylelint cache 63 | .stylelintcache 64 | 65 | # Microbundle cache 66 | .rpt2_cache/ 67 | .rts2_cache_cjs/ 68 | .rts2_cache_es/ 69 | .rts2_cache_umd/ 70 | 71 | # Optional REPL history 72 | .node_repl_history 73 | 74 | # Output of 'npm pack' 75 | *.tgz 76 | 77 | # Yarn Integrity file 78 | .yarn-integrity 79 | 80 | # dotenv environment variable files 81 | .env 82 | .env.development.local 83 | .env.test.local 84 | .env.production.local 85 | .env.local 86 | 87 | # parcel-bundler cache (https://parceljs.org/) 88 | .cache 89 | .parcel-cache 90 | 91 | # Next.js build output 92 | .next 93 | out 94 | 95 | # Nuxt.js build / generate output 96 | .nuxt 97 | dist 98 | 99 | # Gatsby files 100 | .cache/ 101 | # Comment in the public line in if your project uses Gatsby and not Next.js 102 | # https://nextjs.org/blog/next-9-1#public-directory-support 103 | # public 104 | 105 | # vuepress build output 106 | .vuepress/dist 107 | 108 | # vuepress v2.x temp and cache directory 109 | .temp 110 | 111 | # Docusaurus cache and generated files 112 | .docusaurus 113 | 114 | # Serverless directories 115 | .serverless/ 116 | 117 | # FuseBox cache 118 | .fusebox/ 119 | 120 | # DynamoDB Local files 121 | .dynamodb/ 122 | 123 | # TernJS port file 124 | .tern-port 125 | 126 | # Stores VSCode versions used for testing VSCode extensions 127 | .vscode-test 128 | 129 | # yarn v2 130 | .yarn/cache 131 | .yarn/unplugged 132 | .yarn/build-state.yml 133 | .yarn/install-state.gz 134 | .pnp.* 135 | 136 | ### Node Patch ### 137 | # Serverless Webpack directories 138 | .webpack/ 139 | 140 | # Optional stylelint cache 141 | 142 | # SvelteKit build / generate output 143 | .svelte-kit 144 | 145 | # End of https://www.toptal.com/developers/gitignore/api/node 146 | 147 | # OS 148 | ## Mac 149 | .DS_Store 150 | -------------------------------------------------------------------------------- /deno-1.14/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/mod.ts`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /deno-1.14/src/deps.ts: -------------------------------------------------------------------------------- 1 | export * as sdk from "https://deno.land/x/appwrite@6.0.0/mod.ts"; 2 | -------------------------------------------------------------------------------- /deno-1.14/src/mod.ts: -------------------------------------------------------------------------------- 1 | import { sdk } from "./deps.ts"; 2 | 3 | /* 4 | 'req' variable has: 5 | 'headers' - object with request headers 6 | 'payload' - request body data as a string 7 | 'variables' - object with function variables 8 | 9 | 'res' variable has: 10 | 'send(text, status)' - function to return text response. Status code defaults to 200 11 | 'json(obj, status)' - function to return JSON response. Status code defaults to 200 12 | 13 | If an error is thrown, a response with code 500 will be returned. 14 | */ 15 | 16 | export default async function (req: any, res: any) { 17 | const client = new sdk.Client(); 18 | 19 | // You can remove services you don't use 20 | const account = new sdk.Account(client); 21 | const avatars = new sdk.Avatars(client); 22 | const database = new sdk.Databases(client); 23 | const functions = new sdk.Functions(client); 24 | const health = new sdk.Health(client); 25 | const locale = new sdk.Locale(client); 26 | const storage = new sdk.Storage(client); 27 | const teams = new sdk.Teams(client); 28 | const users = new sdk.Users(client); 29 | 30 | if (!req.variables['APPWRITE_FUNCTION_ENDPOINT'] || !req.variables['APPWRITE_FUNCTION_API_KEY']) { 31 | console.warn("Environment variables are not set. Function cannot use Appwrite SDK."); 32 | } else { 33 | client 34 | .setEndpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT'] as string) 35 | .setProject(req.variables['APPWRITE_FUNCTION_PROJECT_ID'] as string) 36 | .setKey(req.variables['APPWRITE_FUNCTION_API_KEY'] as string); 37 | } 38 | 39 | res.json({ 40 | areDevelopersAwesome: true, 41 | }); 42 | } -------------------------------------------------------------------------------- /deno-1.21/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/node 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=node 4 | 5 | ### Node ### 6 | # Logs 7 | logs 8 | *.log 9 | npm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | lerna-debug.log* 13 | .pnpm-debug.log* 14 | 15 | # Diagnostic reports (https://nodejs.org/api/report.html) 16 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | *.pid.lock 23 | 24 | # Directory for instrumented libs generated by jscoverage/JSCover 25 | lib-cov 26 | 27 | # Coverage directory used by tools like istanbul 28 | coverage 29 | *.lcov 30 | 31 | # nyc test coverage 32 | .nyc_output 33 | 34 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 35 | .grunt 36 | 37 | # Bower dependency directory (https://bower.io/) 38 | bower_components 39 | 40 | # node-waf configuration 41 | .lock-wscript 42 | 43 | # Compiled binary addons (https://nodejs.org/api/addons.html) 44 | build/Release 45 | 46 | # Dependency directories 47 | node_modules/ 48 | jspm_packages/ 49 | 50 | # Snowpack dependency directory (https://snowpack.dev/) 51 | web_modules/ 52 | 53 | # TypeScript cache 54 | *.tsbuildinfo 55 | 56 | # Optional npm cache directory 57 | .npm 58 | 59 | # Optional eslint cache 60 | .eslintcache 61 | 62 | # Optional stylelint cache 63 | .stylelintcache 64 | 65 | # Microbundle cache 66 | .rpt2_cache/ 67 | .rts2_cache_cjs/ 68 | .rts2_cache_es/ 69 | .rts2_cache_umd/ 70 | 71 | # Optional REPL history 72 | .node_repl_history 73 | 74 | # Output of 'npm pack' 75 | *.tgz 76 | 77 | # Yarn Integrity file 78 | .yarn-integrity 79 | 80 | # dotenv environment variable files 81 | .env 82 | .env.development.local 83 | .env.test.local 84 | .env.production.local 85 | .env.local 86 | 87 | # parcel-bundler cache (https://parceljs.org/) 88 | .cache 89 | .parcel-cache 90 | 91 | # Next.js build output 92 | .next 93 | out 94 | 95 | # Nuxt.js build / generate output 96 | .nuxt 97 | dist 98 | 99 | # Gatsby files 100 | .cache/ 101 | # Comment in the public line in if your project uses Gatsby and not Next.js 102 | # https://nextjs.org/blog/next-9-1#public-directory-support 103 | # public 104 | 105 | # vuepress build output 106 | .vuepress/dist 107 | 108 | # vuepress v2.x temp and cache directory 109 | .temp 110 | 111 | # Docusaurus cache and generated files 112 | .docusaurus 113 | 114 | # Serverless directories 115 | .serverless/ 116 | 117 | # FuseBox cache 118 | .fusebox/ 119 | 120 | # DynamoDB Local files 121 | .dynamodb/ 122 | 123 | # TernJS port file 124 | .tern-port 125 | 126 | # Stores VSCode versions used for testing VSCode extensions 127 | .vscode-test 128 | 129 | # yarn v2 130 | .yarn/cache 131 | .yarn/unplugged 132 | .yarn/build-state.yml 133 | .yarn/install-state.gz 134 | .pnp.* 135 | 136 | ### Node Patch ### 137 | # Serverless Webpack directories 138 | .webpack/ 139 | 140 | # Optional stylelint cache 141 | 142 | # SvelteKit build / generate output 143 | .svelte-kit 144 | 145 | # End of https://www.toptal.com/developers/gitignore/api/node 146 | 147 | # OS 148 | ## Mac 149 | .DS_Store 150 | -------------------------------------------------------------------------------- /deno-1.21/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/mod.ts`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /deno-1.21/src/deps.ts: -------------------------------------------------------------------------------- 1 | export * as sdk from "https://deno.land/x/appwrite@6.0.0/mod.ts"; 2 | -------------------------------------------------------------------------------- /deno-1.21/src/mod.ts: -------------------------------------------------------------------------------- 1 | import { sdk } from "./deps.ts"; 2 | 3 | /* 4 | 'req' variable has: 5 | 'headers' - object with request headers 6 | 'payload' - request body data as a string 7 | 'variables' - object with function variables 8 | 9 | 'res' variable has: 10 | 'send(text, status)' - function to return text response. Status code defaults to 200 11 | 'json(obj, status)' - function to return JSON response. Status code defaults to 200 12 | 13 | If an error is thrown, a response with code 500 will be returned. 14 | */ 15 | 16 | export default async function (req: any, res: any) { 17 | const client = new sdk.Client(); 18 | 19 | // You can remove services you don't use 20 | const account = new sdk.Account(client); 21 | const avatars = new sdk.Avatars(client); 22 | const database = new sdk.Databases(client); 23 | const functions = new sdk.Functions(client); 24 | const health = new sdk.Health(client); 25 | const locale = new sdk.Locale(client); 26 | const storage = new sdk.Storage(client); 27 | const teams = new sdk.Teams(client); 28 | const users = new sdk.Users(client); 29 | 30 | if (!req.variables['APPWRITE_FUNCTION_ENDPOINT'] || !req.variables['APPWRITE_FUNCTION_API_KEY']) { 31 | console.warn("Environment variables are not set. Function cannot use Appwrite SDK."); 32 | } else { 33 | client 34 | .setEndpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT'] as string) 35 | .setProject(req.variables['APPWRITE_FUNCTION_PROJECT_ID'] as string) 36 | .setKey(req.variables['APPWRITE_FUNCTION_API_KEY'] as string); 37 | } 38 | 39 | res.json({ 40 | areDevelopersAwesome: true, 41 | }); 42 | } -------------------------------------------------------------------------------- /deno-1.24/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/node 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=node 4 | 5 | ### Node ### 6 | # Logs 7 | logs 8 | *.log 9 | npm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | lerna-debug.log* 13 | .pnpm-debug.log* 14 | 15 | # Diagnostic reports (https://nodejs.org/api/report.html) 16 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | *.pid.lock 23 | 24 | # Directory for instrumented libs generated by jscoverage/JSCover 25 | lib-cov 26 | 27 | # Coverage directory used by tools like istanbul 28 | coverage 29 | *.lcov 30 | 31 | # nyc test coverage 32 | .nyc_output 33 | 34 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 35 | .grunt 36 | 37 | # Bower dependency directory (https://bower.io/) 38 | bower_components 39 | 40 | # node-waf configuration 41 | .lock-wscript 42 | 43 | # Compiled binary addons (https://nodejs.org/api/addons.html) 44 | build/Release 45 | 46 | # Dependency directories 47 | node_modules/ 48 | jspm_packages/ 49 | 50 | # Snowpack dependency directory (https://snowpack.dev/) 51 | web_modules/ 52 | 53 | # TypeScript cache 54 | *.tsbuildinfo 55 | 56 | # Optional npm cache directory 57 | .npm 58 | 59 | # Optional eslint cache 60 | .eslintcache 61 | 62 | # Optional stylelint cache 63 | .stylelintcache 64 | 65 | # Microbundle cache 66 | .rpt2_cache/ 67 | .rts2_cache_cjs/ 68 | .rts2_cache_es/ 69 | .rts2_cache_umd/ 70 | 71 | # Optional REPL history 72 | .node_repl_history 73 | 74 | # Output of 'npm pack' 75 | *.tgz 76 | 77 | # Yarn Integrity file 78 | .yarn-integrity 79 | 80 | # dotenv environment variable files 81 | .env 82 | .env.development.local 83 | .env.test.local 84 | .env.production.local 85 | .env.local 86 | 87 | # parcel-bundler cache (https://parceljs.org/) 88 | .cache 89 | .parcel-cache 90 | 91 | # Next.js build output 92 | .next 93 | out 94 | 95 | # Nuxt.js build / generate output 96 | .nuxt 97 | dist 98 | 99 | # Gatsby files 100 | .cache/ 101 | # Comment in the public line in if your project uses Gatsby and not Next.js 102 | # https://nextjs.org/blog/next-9-1#public-directory-support 103 | # public 104 | 105 | # vuepress build output 106 | .vuepress/dist 107 | 108 | # vuepress v2.x temp and cache directory 109 | .temp 110 | 111 | # Docusaurus cache and generated files 112 | .docusaurus 113 | 114 | # Serverless directories 115 | .serverless/ 116 | 117 | # FuseBox cache 118 | .fusebox/ 119 | 120 | # DynamoDB Local files 121 | .dynamodb/ 122 | 123 | # TernJS port file 124 | .tern-port 125 | 126 | # Stores VSCode versions used for testing VSCode extensions 127 | .vscode-test 128 | 129 | # yarn v2 130 | .yarn/cache 131 | .yarn/unplugged 132 | .yarn/build-state.yml 133 | .yarn/install-state.gz 134 | .pnp.* 135 | 136 | ### Node Patch ### 137 | # Serverless Webpack directories 138 | .webpack/ 139 | 140 | # Optional stylelint cache 141 | 142 | # SvelteKit build / generate output 143 | .svelte-kit 144 | 145 | # End of https://www.toptal.com/developers/gitignore/api/node 146 | 147 | # OS 148 | ## Mac 149 | .DS_Store 150 | -------------------------------------------------------------------------------- /deno-1.24/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/mod.ts`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /deno-1.24/src/deps.ts: -------------------------------------------------------------------------------- 1 | export * as sdk from "https://deno.land/x/appwrite@6.0.0/mod.ts"; 2 | -------------------------------------------------------------------------------- /deno-1.24/src/mod.ts: -------------------------------------------------------------------------------- 1 | import { sdk } from "./deps.ts"; 2 | 3 | /* 4 | 'req' variable has: 5 | 'headers' - object with request headers 6 | 'payload' - request body data as a string 7 | 'variables' - object with function variables 8 | 9 | 'res' variable has: 10 | 'send(text, status)' - function to return text response. Status code defaults to 200 11 | 'json(obj, status)' - function to return JSON response. Status code defaults to 200 12 | 13 | If an error is thrown, a response with code 500 will be returned. 14 | */ 15 | 16 | export default async function (req: any, res: any) { 17 | const client = new sdk.Client(); 18 | 19 | // You can remove services you don't use 20 | const account = new sdk.Account(client); 21 | const avatars = new sdk.Avatars(client); 22 | const database = new sdk.Databases(client); 23 | const functions = new sdk.Functions(client); 24 | const health = new sdk.Health(client); 25 | const locale = new sdk.Locale(client); 26 | const storage = new sdk.Storage(client); 27 | const teams = new sdk.Teams(client); 28 | const users = new sdk.Users(client); 29 | 30 | if (!req.variables['APPWRITE_FUNCTION_ENDPOINT'] || !req.variables['APPWRITE_FUNCTION_API_KEY']) { 31 | console.warn("Environment variables are not set. Function cannot use Appwrite SDK."); 32 | } else { 33 | client 34 | .setEndpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT'] as string) 35 | .setProject(req.variables['APPWRITE_FUNCTION_PROJECT_ID'] as string) 36 | .setKey(req.variables['APPWRITE_FUNCTION_API_KEY'] as string); 37 | } 38 | 39 | res.json({ 40 | areDevelopersAwesome: true, 41 | }); 42 | } -------------------------------------------------------------------------------- /dotnet-3.1/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | [Ww][Ii][Nn]32/ 21 | [Aa][Rr][Mm]/ 22 | [Aa][Rr][Mm]64/ 23 | bld/ 24 | [Bb]in/ 25 | [Oo]bj/ 26 | [Ll]og/ 27 | [Ll]ogs/ 28 | 29 | # Visual Studio 2015/2017 cache/options directory 30 | .vs/ 31 | # Uncomment if you have tasks that create the project's static files in wwwroot 32 | #wwwroot/ 33 | 34 | # Visual Studio 2017 auto generated files 35 | Generated\ Files/ 36 | 37 | # .NET Core 38 | project.lock.json 39 | project.fragment.lock.json 40 | artifacts/ 41 | 42 | # Files built by Visual Studio 43 | *_i.c 44 | *_p.c 45 | *_h.h 46 | *.ilk 47 | *.meta 48 | *.obj 49 | *.iobj 50 | *.pch 51 | *.pdb 52 | *.ipdb 53 | *.pgc 54 | *.pgd 55 | *.rsp 56 | *.sbr 57 | *.tlb 58 | *.tli 59 | *.tlh 60 | *.tmp 61 | *.tmp_proj 62 | *_wpftmp.csproj 63 | *.log 64 | *.vspscc 65 | *.vssscc 66 | .builds 67 | *.pidb 68 | *.svclog 69 | *.scc 70 | 71 | # Visual Studio profiler 72 | *.psess 73 | *.vsp 74 | *.vspx 75 | *.sap 76 | 77 | # Visual Studio Trace Files 78 | *.e2e 79 | 80 | # ReSharper is a .NET coding add-in 81 | _ReSharper*/ 82 | *.[Rr]e[Ss]harper 83 | *.DotSettings.user 84 | 85 | # TeamCity is a build add-in 86 | _TeamCity* 87 | 88 | # DotCover is a Code Coverage Tool 89 | *.dotCover 90 | 91 | # NuGet Packages 92 | *.nupkg 93 | # NuGet Symbol Packages 94 | *.snupkg 95 | # The packages folder can be ignored because of Package Restore 96 | **/[Pp]ackages/* 97 | # except build/, which is used as an MSBuild target. 98 | !**/[Pp]ackages/build/ 99 | # Uncomment if necessary however generally it will be regenerated when needed 100 | #!**/[Pp]ackages/repositories.config 101 | # NuGet v3's project.json files produces more ignorable files 102 | *.nuget.props 103 | *.nuget.targets 104 | 105 | # Visual Studio cache files 106 | # files ending in .cache can be ignored 107 | *.[Cc]ache 108 | # but keep track of directories ending in .cache 109 | !?*.[Cc]ache/ 110 | 111 | ## 112 | ## Visual studio for Mac 113 | ## 114 | 115 | 116 | # globs 117 | Makefile.in 118 | *.userprefs 119 | *.usertasks 120 | config.make 121 | config.status 122 | aclocal.m4 123 | install-sh 124 | autom4te.cache/ 125 | *.tar.gz 126 | tarballs/ 127 | test-results/ 128 | 129 | # content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore 130 | # General 131 | .DS_Store 132 | .AppleDouble 133 | .LSOverride 134 | 135 | # Files that might appear in the root of a volume 136 | .DocumentRevisions-V100 137 | .fseventsd 138 | .Spotlight-V100 139 | .TemporaryItems 140 | .Trashes 141 | .VolumeIcon.icns 142 | .com.apple.timemachine.donotpresent 143 | 144 | # Folder config file 145 | [Dd]esktop.ini 146 | 147 | # JetBrains Rider 148 | .idea/ 149 | *.sln.iml 150 | 151 | ## 152 | ## Visual Studio Code 153 | ## 154 | .vscode/* 155 | !.vscode/settings.json 156 | !.vscode/tasks.json 157 | !.vscode/launch.json 158 | !.vscode/extensions.json 159 | -------------------------------------------------------------------------------- /dotnet-3.1/Function.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | netcoreapp3.1 6 | Exe 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /dotnet-3.1/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | This cloud function does not need any environment variables by default. 32 | 33 | 34 | ## 🚀 Deployment 35 | 36 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 37 | 38 | ### Using CLI 39 | 40 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 41 | 42 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 43 | 44 | ### Manual using tar.gz 45 | 46 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/Index.cs`, and upload the file we just generated. 47 | -------------------------------------------------------------------------------- /dotnet-3.1/src/Index.cs: -------------------------------------------------------------------------------- 1 | /* 2 | 'req' variable has: 3 | 'Headers' - object with request headers 4 | 'Payload' - request body data as a string 5 | 'variables' - object with function variables 6 | 7 | 'res' variable has: 8 | 'Send(text, status)' - function to return text response. Status code defaults to 200 9 | 'Json(obj, status)' - function to return JSON response. Status code defaults to 200 10 | 11 | If an error is thrown, a response with code 500 will be returned. 12 | */ 13 | 14 | using System.Threading.Tasks; 15 | using System.Collections.Generic; 16 | 17 | public async Task Main(RuntimeRequest req, RuntimeResponse res) 18 | { 19 | // Appwrite's SDK for .NET is currently under the works and shall be available soon 20 | 21 | return res.Json(new Dictionary() 22 | { 23 | { "areDevelopersAwesome", true } 24 | }); 25 | } 26 | -------------------------------------------------------------------------------- /dotnet-6.0/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | [Ww][Ii][Nn]32/ 21 | [Aa][Rr][Mm]/ 22 | [Aa][Rr][Mm]64/ 23 | bld/ 24 | [Bb]in/ 25 | [Oo]bj/ 26 | [Ll]og/ 27 | [Ll]ogs/ 28 | 29 | # Visual Studio 2015/2017 cache/options directory 30 | .vs/ 31 | # Uncomment if you have tasks that create the project's static files in wwwroot 32 | #wwwroot/ 33 | 34 | # Visual Studio 2017 auto generated files 35 | Generated\ Files/ 36 | 37 | # .NET Core 38 | project.lock.json 39 | project.fragment.lock.json 40 | artifacts/ 41 | 42 | # Files built by Visual Studio 43 | *_i.c 44 | *_p.c 45 | *_h.h 46 | *.ilk 47 | *.meta 48 | *.obj 49 | *.iobj 50 | *.pch 51 | *.pdb 52 | *.ipdb 53 | *.pgc 54 | *.pgd 55 | *.rsp 56 | *.sbr 57 | *.tlb 58 | *.tli 59 | *.tlh 60 | *.tmp 61 | *.tmp_proj 62 | *_wpftmp.csproj 63 | *.log 64 | *.vspscc 65 | *.vssscc 66 | .builds 67 | *.pidb 68 | *.svclog 69 | *.scc 70 | 71 | # Visual Studio profiler 72 | *.psess 73 | *.vsp 74 | *.vspx 75 | *.sap 76 | 77 | # Visual Studio Trace Files 78 | *.e2e 79 | 80 | # ReSharper is a .NET coding add-in 81 | _ReSharper*/ 82 | *.[Rr]e[Ss]harper 83 | *.DotSettings.user 84 | 85 | # TeamCity is a build add-in 86 | _TeamCity* 87 | 88 | # DotCover is a Code Coverage Tool 89 | *.dotCover 90 | 91 | # NuGet Packages 92 | *.nupkg 93 | # NuGet Symbol Packages 94 | *.snupkg 95 | # The packages folder can be ignored because of Package Restore 96 | **/[Pp]ackages/* 97 | # except build/, which is used as an MSBuild target. 98 | !**/[Pp]ackages/build/ 99 | # Uncomment if necessary however generally it will be regenerated when needed 100 | #!**/[Pp]ackages/repositories.config 101 | # NuGet v3's project.json files produces more ignorable files 102 | *.nuget.props 103 | *.nuget.targets 104 | 105 | # Visual Studio cache files 106 | # files ending in .cache can be ignored 107 | *.[Cc]ache 108 | # but keep track of directories ending in .cache 109 | !?*.[Cc]ache/ 110 | 111 | ## 112 | ## Visual studio for Mac 113 | ## 114 | 115 | 116 | # globs 117 | Makefile.in 118 | *.userprefs 119 | *.usertasks 120 | config.make 121 | config.status 122 | aclocal.m4 123 | install-sh 124 | autom4te.cache/ 125 | *.tar.gz 126 | tarballs/ 127 | test-results/ 128 | 129 | # content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore 130 | # General 131 | .DS_Store 132 | .AppleDouble 133 | .LSOverride 134 | 135 | # Files that might appear in the root of a volume 136 | .DocumentRevisions-V100 137 | .fseventsd 138 | .Spotlight-V100 139 | .TemporaryItems 140 | .Trashes 141 | .VolumeIcon.icns 142 | .com.apple.timemachine.donotpresent 143 | 144 | # Folder config file 145 | [Dd]esktop.ini 146 | 147 | # JetBrains Rider 148 | .idea/ 149 | *.sln.iml 150 | 151 | ## 152 | ## Visual Studio Code 153 | ## 154 | .vscode/* 155 | !.vscode/settings.json 156 | !.vscode/tasks.json 157 | !.vscode/launch.json 158 | !.vscode/extensions.json 159 | -------------------------------------------------------------------------------- /dotnet-6.0/Function.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | net6.0 6 | Exe 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /dotnet-6.0/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | This cloud function does not need any environment variables by default. 32 | 33 | 34 | ## 🚀 Deployment 35 | 36 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 37 | 38 | ### Using CLI 39 | 40 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 41 | 42 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 43 | 44 | ### Manual using tar.gz 45 | 46 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/Index.cs`, and upload the file we just generated. 47 | -------------------------------------------------------------------------------- /dotnet-6.0/src/Index.cs: -------------------------------------------------------------------------------- 1 | /* 2 | 'req' variable has: 3 | 'Headers' - object with request headers 4 | 'Payload' - request body data as a string 5 | 'variables' - object with function variables 6 | 7 | 'res' variable has: 8 | 'Send(text, status)' - function to return text response. Status code defaults to 200 9 | 'Json(obj, status)' - function to return JSON response. Status code defaults to 200 10 | 11 | If an error is thrown, a response with code 500 will be returned. 12 | */ 13 | 14 | using System.Threading.Tasks; 15 | using System.Collections.Generic; 16 | 17 | public async Task Main(RuntimeRequest req, RuntimeResponse res) 18 | { 19 | // Appwrite's SDK for .NET is currently under the works and shall be available soon 20 | 21 | return res.Json(new() 22 | { 23 | { "areDevelopersAwesome", true } 24 | }); 25 | } 26 | -------------------------------------------------------------------------------- /java-11.0/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - No special environment variables are required for the cloud function. 34 | 35 | ## 🚀 Deployment 36 | 37 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 38 | 39 | ### Using CLI 40 | 41 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 42 | 43 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 44 | 45 | ### Manual using tar.gz 46 | 47 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/Index.java`, and upload the file we just generated. 48 | -------------------------------------------------------------------------------- /java-11.0/deps.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation 'io.appwrite:sdk-for-kotlin:1.2.0' 3 | } -------------------------------------------------------------------------------- /java-11.0/src/Index.java: -------------------------------------------------------------------------------- 1 | import java.util.Map; 2 | import java.util.HashMap; 3 | import java.net.HttpURLConnection; 4 | import java.net.URL; 5 | import java.io.BufferedReader; 6 | import java.io.InputStreamReader; 7 | import com.google.gson.Gson; 8 | import io.appwrite.Client; 9 | import io.appwrite.services.Account; 10 | import io.appwrite.services.Avatars; 11 | import io.appwrite.services.Databases; 12 | import io.appwrite.services.Functions; 13 | import io.appwrite.services.Health; 14 | import io.appwrite.services.Locale; 15 | import io.appwrite.services.Storage; 16 | import io.appwrite.services.Teams; 17 | import io.appwrite.services.Users; 18 | 19 | /* 20 | 'req' variable has: 21 | 'getHeaders()' - function to get headers as a Map 22 | 'getPayload()' - function to get body data as a String 23 | 'getVariables()' - function to get variables as a Map 24 | 25 | 'res' variable has: 26 | 'send(text, status)' - function that accepts a String to return text response. Status code defaults to 200 27 | 'json(obj, status)' - function that accepts a Map to return JSON response. Status code defaults to 200 28 | 29 | If an error is thrown, a response with code 500 will be returned. 30 | */ 31 | 32 | final Gson gson = new Gson(); 33 | 34 | public RuntimeResponse main(RuntimeRequest req, RuntimeResponse res) throws Exception { 35 | var client = new Client(); 36 | 37 | // You can remove services you don't use 38 | var account = new Account(client); 39 | var avatars = new Avatars(client); 40 | var database = new Databases(client); 41 | var functions = new Functions(client); 42 | var health = new Health(client); 43 | var locale = new Locale(client); 44 | var storage = new Storage(client); 45 | var teams = new Teams(client); 46 | var users = new Users(client); 47 | 48 | var variables = req.getVariables(); 49 | 50 | if (variables == null 51 | || !variables.containsKey("APPWRITE_FUNCTION_ENDPOINT") 52 | || !variables.containsKey("APPWRITE_FUNCTION_API_KEY") 53 | || variables.get("APPWRITE_FUNCTION_ENDPOINT") == null 54 | || variables.get("APPWRITE_FUNCTION_API_KEY") == null) { 55 | System.out.println("Environment variables are not set. Function cannot use Appwrite SDK."); 56 | } else { 57 | client 58 | .setEndpoint(variables.get("APPWRITE_FUNCTION_ENDPOINT")) 59 | .setProject(variables.get("APPWRITE_FUNCTION_PROJECT_ID")) 60 | .setKey(variables.get("APPWRITE_FUNCTION_API_KEY")); 61 | } 62 | 63 | return res.json(Map.of( 64 | "areDevelopersAwesome", true 65 | )); 66 | } 67 | -------------------------------------------------------------------------------- /java-17.0/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - No special environment variables are required for the cloud function. 34 | 35 | ## 🚀 Deployment 36 | 37 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 38 | 39 | ### Using CLI 40 | 41 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 42 | 43 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 44 | 45 | ### Manual using tar.gz 46 | 47 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/Index.java`, and upload the file we just generated. 48 | -------------------------------------------------------------------------------- /java-17.0/deps.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation 'io.appwrite:sdk-for-kotlin:1.2.0' 3 | } -------------------------------------------------------------------------------- /java-17.0/src/Index.java: -------------------------------------------------------------------------------- 1 | import java.util.Map; 2 | import java.util.HashMap; 3 | import java.net.HttpURLConnection; 4 | import java.net.URL; 5 | import java.io.BufferedReader; 6 | import java.io.InputStreamReader; 7 | import com.google.gson.Gson; 8 | import io.appwrite.Client; 9 | import io.appwrite.services.Account; 10 | import io.appwrite.services.Avatars; 11 | import io.appwrite.services.Databases; 12 | import io.appwrite.services.Functions; 13 | import io.appwrite.services.Health; 14 | import io.appwrite.services.Locale; 15 | import io.appwrite.services.Storage; 16 | import io.appwrite.services.Teams; 17 | import io.appwrite.services.Users; 18 | 19 | /* 20 | 'req' variable has: 21 | 'getHeaders()' - function to get headers as a Map 22 | 'getPayload()' - function to get body data as a String 23 | 'getVariables()' - function to get variables as a Map 24 | 25 | 'res' variable has: 26 | 'send(text, status)' - function that accepts a String to return text response. Status code defaults to 200 27 | 'json(obj, status)' - function that accepts a Map to return JSON response. Status code defaults to 200 28 | 29 | If an error is thrown, a response with code 500 will be returned. 30 | */ 31 | 32 | final Gson gson = new Gson(); 33 | 34 | public RuntimeResponse main(RuntimeRequest req, RuntimeResponse res) throws Exception { 35 | var client = new Client(); 36 | 37 | // You can remove services you don't use 38 | var account = new Account(client); 39 | var avatars = new Avatars(client); 40 | var database = new Databases(client); 41 | var functions = new Functions(client); 42 | var health = new Health(client); 43 | var locale = new Locale(client); 44 | var storage = new Storage(client); 45 | var teams = new Teams(client); 46 | var users = new Users(client); 47 | 48 | var variables = req.getVariables(); 49 | 50 | if (variables == null 51 | || !variables.containsKey("APPWRITE_FUNCTION_ENDPOINT") 52 | || !variables.containsKey("APPWRITE_FUNCTION_API_KEY") 53 | || variables.get("APPWRITE_FUNCTION_ENDPOINT") == null 54 | || variables.get("APPWRITE_FUNCTION_API_KEY") == null) { 55 | System.out.println("Environment variables are not set. Function cannot use Appwrite SDK."); 56 | } else { 57 | client 58 | .setEndpoint(variables.get("APPWRITE_FUNCTION_ENDPOINT")) 59 | .setProject(variables.get("APPWRITE_FUNCTION_PROJECT_ID")) 60 | .setKey(variables.get("APPWRITE_FUNCTION_API_KEY")); 61 | } 62 | 63 | return res.json(Map.of( 64 | "areDevelopersAwesome", true 65 | )); 66 | } 67 | -------------------------------------------------------------------------------- /java-18.0/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - No special environment variables are required for the cloud function. 34 | 35 | ## 🚀 Deployment 36 | 37 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 38 | 39 | ### Using CLI 40 | 41 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 42 | 43 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 44 | 45 | ### Manual using tar.gz 46 | 47 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/Index.java`, and upload the file we just generated. 48 | -------------------------------------------------------------------------------- /java-18.0/deps.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation 'io.appwrite:sdk-for-kotlin:1.2.0' 3 | } -------------------------------------------------------------------------------- /java-18.0/src/Index.java: -------------------------------------------------------------------------------- 1 | import java.util.Map; 2 | import java.util.HashMap; 3 | import java.net.HttpURLConnection; 4 | import java.net.URL; 5 | import java.io.BufferedReader; 6 | import java.io.InputStreamReader; 7 | import com.google.gson.Gson; 8 | import io.appwrite.Client; 9 | import io.appwrite.services.Account; 10 | import io.appwrite.services.Avatars; 11 | import io.appwrite.services.Databases; 12 | import io.appwrite.services.Functions; 13 | import io.appwrite.services.Health; 14 | import io.appwrite.services.Locale; 15 | import io.appwrite.services.Storage; 16 | import io.appwrite.services.Teams; 17 | import io.appwrite.services.Users; 18 | 19 | /* 20 | 'req' variable has: 21 | 'getHeaders()' - function to get headers as a Map 22 | 'getPayload()' - function to get body data as a String 23 | 'getVariables()' - function to get variables as a Map 24 | 25 | 'res' variable has: 26 | 'send(text, status)' - function that accepts a String to return text response. Status code defaults to 200 27 | 'json(obj, status)' - function that accepts a Map to return JSON response. Status code defaults to 200 28 | 29 | If an error is thrown, a response with code 500 will be returned. 30 | */ 31 | 32 | final Gson gson = new Gson(); 33 | 34 | public RuntimeResponse main(RuntimeRequest req, RuntimeResponse res) throws Exception { 35 | var client = new Client(); 36 | 37 | // You can remove services you don't use 38 | var account = new Account(client); 39 | var avatars = new Avatars(client); 40 | var database = new Databases(client); 41 | var functions = new Functions(client); 42 | var health = new Health(client); 43 | var locale = new Locale(client); 44 | var storage = new Storage(client); 45 | var teams = new Teams(client); 46 | var users = new Users(client); 47 | 48 | var variables = req.getVariables(); 49 | 50 | if (variables == null 51 | || !variables.containsKey("APPWRITE_FUNCTION_ENDPOINT") 52 | || !variables.containsKey("APPWRITE_FUNCTION_API_KEY") 53 | || variables.get("APPWRITE_FUNCTION_ENDPOINT") == null 54 | || variables.get("APPWRITE_FUNCTION_API_KEY") == null) { 55 | System.out.println("Environment variables are not set. Function cannot use Appwrite SDK."); 56 | } else { 57 | client 58 | .setEndpoint(variables.get("APPWRITE_FUNCTION_ENDPOINT")) 59 | .setProject(variables.get("APPWRITE_FUNCTION_PROJECT_ID")) 60 | .setKey(variables.get("APPWRITE_FUNCTION_API_KEY")); 61 | } 62 | 63 | return res.json(Map.of( 64 | "areDevelopersAwesome", true 65 | )); 66 | } 67 | -------------------------------------------------------------------------------- /java-8.0/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - No special environment variables are required for the cloud function. 34 | 35 | ## 🚀 Deployment 36 | 37 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 38 | 39 | ### Using CLI 40 | 41 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 42 | 43 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 44 | 45 | ### Manual using tar.gz 46 | 47 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/Index.java`, and upload the file we just generated. 48 | -------------------------------------------------------------------------------- /java-8.0/deps.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation 'io.appwrite:sdk-for-kotlin:1.2.0' 3 | } -------------------------------------------------------------------------------- /java-8.0/src/Index.java: -------------------------------------------------------------------------------- 1 | import java.util.Map; 2 | import java.util.HashMap; 3 | import java.net.HttpURLConnection; 4 | import java.net.URL; 5 | import java.io.BufferedReader; 6 | import java.io.InputStreamReader; 7 | import com.google.gson.Gson; 8 | import io.appwrite.Client; 9 | import io.appwrite.services.Account; 10 | import io.appwrite.services.Avatars; 11 | import io.appwrite.services.Databases; 12 | import io.appwrite.services.Functions; 13 | import io.appwrite.services.Health; 14 | import io.appwrite.services.Locale; 15 | import io.appwrite.services.Storage; 16 | import io.appwrite.services.Teams; 17 | import io.appwrite.services.Users; 18 | 19 | /* 20 | 'req' variable has: 21 | 'getHeaders()' - function to get headers as a Map 22 | 'getPayload()' - function to get body data as a String 23 | 'getVariables()' - function to get variables as a Map 24 | 25 | 'res' variable has: 26 | 'send(text, status)' - function that accepts a String to return text response. Status code defaults to 200 27 | 'json(obj, status)' - function that accepts a Map to return JSON response. Status code defaults to 200 28 | 29 | If an error is thrown, a response with code 500 will be returned. 30 | */ 31 | 32 | final Gson gson = new Gson(); 33 | 34 | public RuntimeResponse main(RuntimeRequest req, RuntimeResponse res) throws Exception { 35 | final Client client = new Client(); 36 | 37 | // You can remove services you don't use 38 | Account account = new Account(client); 39 | Avatars avatars = new Avatars(client); 40 | Databases database = new Databases(client); 41 | Functions functions = new Functions(client); 42 | Health health = new Health(client); 43 | Locale locale = new Locale(client); 44 | Storage storage = new Storage(client); 45 | Teams teams = new Teams(client); 46 | Users users = new Users(client); 47 | 48 | Map variables = req.getVariables(); 49 | 50 | if (variables == null 51 | || !variables.containsKey("APPWRITE_FUNCTION_ENDPOINT") 52 | || !variables.containsKey("APPWRITE_FUNCTION_API_KEY") 53 | || variables.get("APPWRITE_FUNCTION_ENDPOINT") == null 54 | || variables.get("APPWRITE_FUNCTION_API_KEY") == null) { 55 | System.out.println("Environment variables are not set. Function cannot use Appwrite SDK."); 56 | } else { 57 | client 58 | .setEndpoint(variables.get("APPWRITE_FUNCTION_ENDPOINT")) 59 | .setProject(variables.get("APPWRITE_FUNCTION_PROJECT_ID")) 60 | .setKey(variables.get("APPWRITE_FUNCTION_API_KEY")); 61 | } 62 | 63 | Map data = new HashMap<>(); 64 | data.put("areDevelopersAwesome", true); 65 | 66 | return res.json(data); 67 | } 68 | -------------------------------------------------------------------------------- /kotlin-1.6/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/Index.kt`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /kotlin-1.6/deps.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation 'io.appwrite:sdk-for-kotlin:1.2.0' 3 | } -------------------------------------------------------------------------------- /kotlin-1.6/src/Index.kt: -------------------------------------------------------------------------------- 1 | import java.util.Map 2 | import java.util.HashMap 3 | import java.net.HttpURLConnection 4 | import java.net.URL 5 | import java.io.BufferedReader 6 | import java.io.InputStreamReader 7 | import com.google.gson.Gson 8 | import io.appwrite.Client 9 | import io.appwrite.services.Account 10 | import io.appwrite.services.Avatars 11 | import io.appwrite.services.Databases 12 | import io.appwrite.services.Functions 13 | import io.appwrite.services.Health 14 | import io.appwrite.services.Locale 15 | import io.appwrite.services.Storage 16 | import io.appwrite.services.Teams 17 | import io.appwrite.services.Users 18 | 19 | /* 20 | 'req' variable has: 21 | 'headers' - object with request headers 22 | 'payload' - request body data as a string 23 | 'variables' - object with function variables 24 | 25 | 'res' variable has: 26 | 'send(text, status)' - function to return text response. Status code defaults to 200 27 | 'json(obj, status)' - function to return JSON response. Status code defaults to 200 28 | 29 | If an error is thrown, a response with code 500 will be returned. 30 | */ 31 | 32 | private val gson = Gson() 33 | 34 | @Throws(Exception::class) 35 | fun main(req: RuntimeRequest, res: RuntimeResponse): RuntimeResponse { 36 | val client = Client() 37 | 38 | // You can remove services you don't use 39 | val account = Account(client) 40 | val avatars = Avatars(client) 41 | val database = Databases(client) 42 | val functions = Functions(client) 43 | val health = Health(client) 44 | val locale = Locale(client) 45 | val storage = Storage(client) 46 | val teams = Teams(client) 47 | val users = Users(client) 48 | 49 | if (req.variables["APPWRITE_FUNCTION_ENDPOINT"] == null || req.variables["APPWRITE_FUNCTION_API_KEY"] == null) { 50 | println("Environment variables are not set. Function cannot use Appwrite SDK.") 51 | } else { 52 | client 53 | .setEndpoint(req.variables["APPWRITE_FUNCTION_ENDPOINT"]!!) 54 | .setProject(req.variables["APPWRITE_FUNCTION_PROJECT_ID"]!!) 55 | .setKey(req.variables["APPWRITE_FUNCTION_API_KEY"]!!) 56 | } 57 | 58 | return res.json(mapOf( 59 | "areDevelopersAwesome" to true 60 | )) 61 | } 62 | -------------------------------------------------------------------------------- /node-14.5/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/node 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=node 4 | 5 | ### Node ### 6 | # Logs 7 | logs 8 | *.log 9 | npm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | lerna-debug.log* 13 | .pnpm-debug.log* 14 | 15 | # Diagnostic reports (https://nodejs.org/api/report.html) 16 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | *.pid.lock 23 | 24 | # Directory for instrumented libs generated by jscoverage/JSCover 25 | lib-cov 26 | 27 | # Coverage directory used by tools like istanbul 28 | coverage 29 | *.lcov 30 | 31 | # nyc test coverage 32 | .nyc_output 33 | 34 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 35 | .grunt 36 | 37 | # Bower dependency directory (https://bower.io/) 38 | bower_components 39 | 40 | # node-waf configuration 41 | .lock-wscript 42 | 43 | # Compiled binary addons (https://nodejs.org/api/addons.html) 44 | build/Release 45 | 46 | # Dependency directories 47 | node_modules/ 48 | jspm_packages/ 49 | 50 | # Snowpack dependency directory (https://snowpack.dev/) 51 | web_modules/ 52 | 53 | # TypeScript cache 54 | *.tsbuildinfo 55 | 56 | # Optional npm cache directory 57 | .npm 58 | 59 | # Optional eslint cache 60 | .eslintcache 61 | 62 | # Optional stylelint cache 63 | .stylelintcache 64 | 65 | # Microbundle cache 66 | .rpt2_cache/ 67 | .rts2_cache_cjs/ 68 | .rts2_cache_es/ 69 | .rts2_cache_umd/ 70 | 71 | # Optional REPL history 72 | .node_repl_history 73 | 74 | # Output of 'npm pack' 75 | *.tgz 76 | 77 | # Yarn Integrity file 78 | .yarn-integrity 79 | 80 | # dotenv environment variable files 81 | .env 82 | .env.development.local 83 | .env.test.local 84 | .env.production.local 85 | .env.local 86 | 87 | # parcel-bundler cache (https://parceljs.org/) 88 | .cache 89 | .parcel-cache 90 | 91 | # Next.js build output 92 | .next 93 | out 94 | 95 | # Nuxt.js build / generate output 96 | .nuxt 97 | dist 98 | 99 | # Gatsby files 100 | .cache/ 101 | # Comment in the public line in if your project uses Gatsby and not Next.js 102 | # https://nextjs.org/blog/next-9-1#public-directory-support 103 | # public 104 | 105 | # vuepress build output 106 | .vuepress/dist 107 | 108 | # vuepress v2.x temp and cache directory 109 | .temp 110 | 111 | # Docusaurus cache and generated files 112 | .docusaurus 113 | 114 | # Serverless directories 115 | .serverless/ 116 | 117 | # FuseBox cache 118 | .fusebox/ 119 | 120 | # DynamoDB Local files 121 | .dynamodb/ 122 | 123 | # TernJS port file 124 | .tern-port 125 | 126 | # Stores VSCode versions used for testing VSCode extensions 127 | .vscode-test 128 | 129 | # yarn v2 130 | .yarn/cache 131 | .yarn/unplugged 132 | .yarn/build-state.yml 133 | .yarn/install-state.gz 134 | .pnp.* 135 | 136 | ### Node Patch ### 137 | # Serverless Webpack directories 138 | .webpack/ 139 | 140 | # Optional stylelint cache 141 | 142 | # SvelteKit build / generate output 143 | .svelte-kit 144 | 145 | # End of https://www.toptal.com/developers/gitignore/api/node 146 | 147 | # OS 148 | ## Mac 149 | .DS_Store 150 | -------------------------------------------------------------------------------- /node-14.5/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/index.js`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /node-14.5/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "appwrite-function", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "node-appwrite": "^8.0.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /node-14.5/src/index.js: -------------------------------------------------------------------------------- 1 | const sdk = require("node-appwrite"); 2 | 3 | /* 4 | 'req' variable has: 5 | 'headers' - object with request headers 6 | 'payload' - request body data as a string 7 | 'variables' - object with function variables 8 | 9 | 'res' variable has: 10 | 'send(text, status)' - function to return text response. Status code defaults to 200 11 | 'json(obj, status)' - function to return JSON response. Status code defaults to 200 12 | 13 | If an error is thrown, a response with code 500 will be returned. 14 | */ 15 | 16 | module.exports = async function (req, res) { 17 | const client = new sdk.Client(); 18 | 19 | // You can remove services you don't use 20 | const account = new sdk.Account(client); 21 | const avatars = new sdk.Avatars(client); 22 | const database = new sdk.Databases(client); 23 | const functions = new sdk.Functions(client); 24 | const health = new sdk.Health(client); 25 | const locale = new sdk.Locale(client); 26 | const storage = new sdk.Storage(client); 27 | const teams = new sdk.Teams(client); 28 | const users = new sdk.Users(client); 29 | 30 | if ( 31 | !req.variables['APPWRITE_FUNCTION_ENDPOINT'] || 32 | !req.variables['APPWRITE_FUNCTION_API_KEY'] 33 | ) { 34 | console.warn("Environment variables are not set. Function cannot use Appwrite SDK."); 35 | } else { 36 | client 37 | .setEndpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT']) 38 | .setProject(req.variables['APPWRITE_FUNCTION_PROJECT_ID']) 39 | .setKey(req.variables['APPWRITE_FUNCTION_API_KEY']) 40 | .setSelfSigned(true); 41 | } 42 | 43 | res.json({ 44 | areDevelopersAwesome: true, 45 | }); 46 | }; 47 | -------------------------------------------------------------------------------- /node-15.5/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/node 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=node 4 | 5 | ### Node ### 6 | # Logs 7 | logs 8 | *.log 9 | npm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | lerna-debug.log* 13 | .pnpm-debug.log* 14 | 15 | # Diagnostic reports (https://nodejs.org/api/report.html) 16 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | *.pid.lock 23 | 24 | # Directory for instrumented libs generated by jscoverage/JSCover 25 | lib-cov 26 | 27 | # Coverage directory used by tools like istanbul 28 | coverage 29 | *.lcov 30 | 31 | # nyc test coverage 32 | .nyc_output 33 | 34 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 35 | .grunt 36 | 37 | # Bower dependency directory (https://bower.io/) 38 | bower_components 39 | 40 | # node-waf configuration 41 | .lock-wscript 42 | 43 | # Compiled binary addons (https://nodejs.org/api/addons.html) 44 | build/Release 45 | 46 | # Dependency directories 47 | node_modules/ 48 | jspm_packages/ 49 | 50 | # Snowpack dependency directory (https://snowpack.dev/) 51 | web_modules/ 52 | 53 | # TypeScript cache 54 | *.tsbuildinfo 55 | 56 | # Optional npm cache directory 57 | .npm 58 | 59 | # Optional eslint cache 60 | .eslintcache 61 | 62 | # Optional stylelint cache 63 | .stylelintcache 64 | 65 | # Microbundle cache 66 | .rpt2_cache/ 67 | .rts2_cache_cjs/ 68 | .rts2_cache_es/ 69 | .rts2_cache_umd/ 70 | 71 | # Optional REPL history 72 | .node_repl_history 73 | 74 | # Output of 'npm pack' 75 | *.tgz 76 | 77 | # Yarn Integrity file 78 | .yarn-integrity 79 | 80 | # dotenv environment variable files 81 | .env 82 | .env.development.local 83 | .env.test.local 84 | .env.production.local 85 | .env.local 86 | 87 | # parcel-bundler cache (https://parceljs.org/) 88 | .cache 89 | .parcel-cache 90 | 91 | # Next.js build output 92 | .next 93 | out 94 | 95 | # Nuxt.js build / generate output 96 | .nuxt 97 | dist 98 | 99 | # Gatsby files 100 | .cache/ 101 | # Comment in the public line in if your project uses Gatsby and not Next.js 102 | # https://nextjs.org/blog/next-9-1#public-directory-support 103 | # public 104 | 105 | # vuepress build output 106 | .vuepress/dist 107 | 108 | # vuepress v2.x temp and cache directory 109 | .temp 110 | 111 | # Docusaurus cache and generated files 112 | .docusaurus 113 | 114 | # Serverless directories 115 | .serverless/ 116 | 117 | # FuseBox cache 118 | .fusebox/ 119 | 120 | # DynamoDB Local files 121 | .dynamodb/ 122 | 123 | # TernJS port file 124 | .tern-port 125 | 126 | # Stores VSCode versions used for testing VSCode extensions 127 | .vscode-test 128 | 129 | # yarn v2 130 | .yarn/cache 131 | .yarn/unplugged 132 | .yarn/build-state.yml 133 | .yarn/install-state.gz 134 | .pnp.* 135 | 136 | ### Node Patch ### 137 | # Serverless Webpack directories 138 | .webpack/ 139 | 140 | # Optional stylelint cache 141 | 142 | # SvelteKit build / generate output 143 | .svelte-kit 144 | 145 | # End of https://www.toptal.com/developers/gitignore/api/node 146 | 147 | # OS 148 | ## Mac 149 | .DS_Store 150 | -------------------------------------------------------------------------------- /node-15.5/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/index.js`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /node-15.5/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "appwrite-function", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "node-appwrite": "^8.0.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /node-15.5/src/index.js: -------------------------------------------------------------------------------- 1 | const sdk = require("node-appwrite"); 2 | 3 | /* 4 | 'req' variable has: 5 | 'headers' - object with request headers 6 | 'payload' - request body data as a string 7 | 'variables' - object with function variables 8 | 9 | 'res' variable has: 10 | 'send(text, status)' - function to return text response. Status code defaults to 200 11 | 'json(obj, status)' - function to return JSON response. Status code defaults to 200 12 | 13 | If an error is thrown, a response with code 500 will be returned. 14 | */ 15 | 16 | module.exports = async function (req, res) { 17 | const client = new sdk.Client(); 18 | 19 | // You can remove services you don't use 20 | const account = new sdk.Account(client); 21 | const avatars = new sdk.Avatars(client); 22 | const database = new sdk.Databases(client); 23 | const functions = new sdk.Functions(client); 24 | const health = new sdk.Health(client); 25 | const locale = new sdk.Locale(client); 26 | const storage = new sdk.Storage(client); 27 | const teams = new sdk.Teams(client); 28 | const users = new sdk.Users(client); 29 | 30 | if ( 31 | !req.variables['APPWRITE_FUNCTION_ENDPOINT'] || 32 | !req.variables['APPWRITE_FUNCTION_API_KEY'] 33 | ) { 34 | console.warn("Environment variables are not set. Function cannot use Appwrite SDK."); 35 | } else { 36 | client 37 | .setEndpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT']) 38 | .setProject(req.variables['APPWRITE_FUNCTION_PROJECT_ID']) 39 | .setKey(req.variables['APPWRITE_FUNCTION_API_KEY']) 40 | .setSelfSigned(true); 41 | } 42 | 43 | res.json({ 44 | areDevelopersAwesome: true, 45 | }); 46 | }; 47 | -------------------------------------------------------------------------------- /node-16.0/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/node 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=node 4 | 5 | ### Node ### 6 | # Logs 7 | logs 8 | *.log 9 | npm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | lerna-debug.log* 13 | .pnpm-debug.log* 14 | 15 | # Diagnostic reports (https://nodejs.org/api/report.html) 16 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | *.pid.lock 23 | 24 | # Directory for instrumented libs generated by jscoverage/JSCover 25 | lib-cov 26 | 27 | # Coverage directory used by tools like istanbul 28 | coverage 29 | *.lcov 30 | 31 | # nyc test coverage 32 | .nyc_output 33 | 34 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 35 | .grunt 36 | 37 | # Bower dependency directory (https://bower.io/) 38 | bower_components 39 | 40 | # node-waf configuration 41 | .lock-wscript 42 | 43 | # Compiled binary addons (https://nodejs.org/api/addons.html) 44 | build/Release 45 | 46 | # Dependency directories 47 | node_modules/ 48 | jspm_packages/ 49 | 50 | # Snowpack dependency directory (https://snowpack.dev/) 51 | web_modules/ 52 | 53 | # TypeScript cache 54 | *.tsbuildinfo 55 | 56 | # Optional npm cache directory 57 | .npm 58 | 59 | # Optional eslint cache 60 | .eslintcache 61 | 62 | # Optional stylelint cache 63 | .stylelintcache 64 | 65 | # Microbundle cache 66 | .rpt2_cache/ 67 | .rts2_cache_cjs/ 68 | .rts2_cache_es/ 69 | .rts2_cache_umd/ 70 | 71 | # Optional REPL history 72 | .node_repl_history 73 | 74 | # Output of 'npm pack' 75 | *.tgz 76 | 77 | # Yarn Integrity file 78 | .yarn-integrity 79 | 80 | # dotenv environment variable files 81 | .env 82 | .env.development.local 83 | .env.test.local 84 | .env.production.local 85 | .env.local 86 | 87 | # parcel-bundler cache (https://parceljs.org/) 88 | .cache 89 | .parcel-cache 90 | 91 | # Next.js build output 92 | .next 93 | out 94 | 95 | # Nuxt.js build / generate output 96 | .nuxt 97 | dist 98 | 99 | # Gatsby files 100 | .cache/ 101 | # Comment in the public line in if your project uses Gatsby and not Next.js 102 | # https://nextjs.org/blog/next-9-1#public-directory-support 103 | # public 104 | 105 | # vuepress build output 106 | .vuepress/dist 107 | 108 | # vuepress v2.x temp and cache directory 109 | .temp 110 | 111 | # Docusaurus cache and generated files 112 | .docusaurus 113 | 114 | # Serverless directories 115 | .serverless/ 116 | 117 | # FuseBox cache 118 | .fusebox/ 119 | 120 | # DynamoDB Local files 121 | .dynamodb/ 122 | 123 | # TernJS port file 124 | .tern-port 125 | 126 | # Stores VSCode versions used for testing VSCode extensions 127 | .vscode-test 128 | 129 | # yarn v2 130 | .yarn/cache 131 | .yarn/unplugged 132 | .yarn/build-state.yml 133 | .yarn/install-state.gz 134 | .pnp.* 135 | 136 | ### Node Patch ### 137 | # Serverless Webpack directories 138 | .webpack/ 139 | 140 | # Optional stylelint cache 141 | 142 | # SvelteKit build / generate output 143 | .svelte-kit 144 | 145 | # End of https://www.toptal.com/developers/gitignore/api/node 146 | 147 | # OS 148 | ## Mac 149 | .DS_Store 150 | -------------------------------------------------------------------------------- /node-16.0/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/index.js`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /node-16.0/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "appwrite-function", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "node-appwrite": "^8.0.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /node-16.0/src/index.js: -------------------------------------------------------------------------------- 1 | const sdk = require("node-appwrite"); 2 | 3 | /* 4 | 'req' variable has: 5 | 'headers' - object with request headers 6 | 'payload' - request body data as a string 7 | 'variables' - object with function variables 8 | 9 | 'res' variable has: 10 | 'send(text, status)' - function to return text response. Status code defaults to 200 11 | 'json(obj, status)' - function to return JSON response. Status code defaults to 200 12 | 13 | If an error is thrown, a response with code 500 will be returned. 14 | */ 15 | 16 | module.exports = async function (req, res) { 17 | const client = new sdk.Client(); 18 | 19 | // You can remove services you don't use 20 | const account = new sdk.Account(client); 21 | const avatars = new sdk.Avatars(client); 22 | const database = new sdk.Databases(client); 23 | const functions = new sdk.Functions(client); 24 | const health = new sdk.Health(client); 25 | const locale = new sdk.Locale(client); 26 | const storage = new sdk.Storage(client); 27 | const teams = new sdk.Teams(client); 28 | const users = new sdk.Users(client); 29 | 30 | if ( 31 | !req.variables['APPWRITE_FUNCTION_ENDPOINT'] || 32 | !req.variables['APPWRITE_FUNCTION_API_KEY'] 33 | ) { 34 | console.warn("Environment variables are not set. Function cannot use Appwrite SDK."); 35 | } else { 36 | client 37 | .setEndpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT']) 38 | .setProject(req.variables['APPWRITE_FUNCTION_PROJECT_ID']) 39 | .setKey(req.variables['APPWRITE_FUNCTION_API_KEY']) 40 | .setSelfSigned(true); 41 | } 42 | 43 | res.json({ 44 | areDevelopersAwesome: true, 45 | }); 46 | }; 47 | -------------------------------------------------------------------------------- /node-17.0/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/node 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=node 4 | 5 | ### Node ### 6 | # Logs 7 | logs 8 | *.log 9 | npm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | lerna-debug.log* 13 | .pnpm-debug.log* 14 | 15 | # Diagnostic reports (https://nodejs.org/api/report.html) 16 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | *.pid.lock 23 | 24 | # Directory for instrumented libs generated by jscoverage/JSCover 25 | lib-cov 26 | 27 | # Coverage directory used by tools like istanbul 28 | coverage 29 | *.lcov 30 | 31 | # nyc test coverage 32 | .nyc_output 33 | 34 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 35 | .grunt 36 | 37 | # Bower dependency directory (https://bower.io/) 38 | bower_components 39 | 40 | # node-waf configuration 41 | .lock-wscript 42 | 43 | # Compiled binary addons (https://nodejs.org/api/addons.html) 44 | build/Release 45 | 46 | # Dependency directories 47 | node_modules/ 48 | jspm_packages/ 49 | 50 | # Snowpack dependency directory (https://snowpack.dev/) 51 | web_modules/ 52 | 53 | # TypeScript cache 54 | *.tsbuildinfo 55 | 56 | # Optional npm cache directory 57 | .npm 58 | 59 | # Optional eslint cache 60 | .eslintcache 61 | 62 | # Optional stylelint cache 63 | .stylelintcache 64 | 65 | # Microbundle cache 66 | .rpt2_cache/ 67 | .rts2_cache_cjs/ 68 | .rts2_cache_es/ 69 | .rts2_cache_umd/ 70 | 71 | # Optional REPL history 72 | .node_repl_history 73 | 74 | # Output of 'npm pack' 75 | *.tgz 76 | 77 | # Yarn Integrity file 78 | .yarn-integrity 79 | 80 | # dotenv environment variable files 81 | .env 82 | .env.development.local 83 | .env.test.local 84 | .env.production.local 85 | .env.local 86 | 87 | # parcel-bundler cache (https://parceljs.org/) 88 | .cache 89 | .parcel-cache 90 | 91 | # Next.js build output 92 | .next 93 | out 94 | 95 | # Nuxt.js build / generate output 96 | .nuxt 97 | dist 98 | 99 | # Gatsby files 100 | .cache/ 101 | # Comment in the public line in if your project uses Gatsby and not Next.js 102 | # https://nextjs.org/blog/next-9-1#public-directory-support 103 | # public 104 | 105 | # vuepress build output 106 | .vuepress/dist 107 | 108 | # vuepress v2.x temp and cache directory 109 | .temp 110 | 111 | # Docusaurus cache and generated files 112 | .docusaurus 113 | 114 | # Serverless directories 115 | .serverless/ 116 | 117 | # FuseBox cache 118 | .fusebox/ 119 | 120 | # DynamoDB Local files 121 | .dynamodb/ 122 | 123 | # TernJS port file 124 | .tern-port 125 | 126 | # Stores VSCode versions used for testing VSCode extensions 127 | .vscode-test 128 | 129 | # yarn v2 130 | .yarn/cache 131 | .yarn/unplugged 132 | .yarn/build-state.yml 133 | .yarn/install-state.gz 134 | .pnp.* 135 | 136 | ### Node Patch ### 137 | # Serverless Webpack directories 138 | .webpack/ 139 | 140 | # Optional stylelint cache 141 | 142 | # SvelteKit build / generate output 143 | .svelte-kit 144 | 145 | # End of https://www.toptal.com/developers/gitignore/api/node 146 | 147 | # OS 148 | ## Mac 149 | .DS_Store 150 | -------------------------------------------------------------------------------- /node-17.0/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/index.js`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /node-17.0/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "appwrite-function", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "node-appwrite": "^8.0.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /node-17.0/src/index.js: -------------------------------------------------------------------------------- 1 | const sdk = require("node-appwrite"); 2 | 3 | /* 4 | 'req' variable has: 5 | 'headers' - object with request headers 6 | 'payload' - request body data as a string 7 | 'variables' - object with function variables 8 | 9 | 'res' variable has: 10 | 'send(text, status)' - function to return text response. Status code defaults to 200 11 | 'json(obj, status)' - function to return JSON response. Status code defaults to 200 12 | 13 | If an error is thrown, a response with code 500 will be returned. 14 | */ 15 | 16 | module.exports = async function (req, res) { 17 | const client = new sdk.Client(); 18 | 19 | // You can remove services you don't use 20 | const account = new sdk.Account(client); 21 | const avatars = new sdk.Avatars(client); 22 | const database = new sdk.Databases(client); 23 | const functions = new sdk.Functions(client); 24 | const health = new sdk.Health(client); 25 | const locale = new sdk.Locale(client); 26 | const storage = new sdk.Storage(client); 27 | const teams = new sdk.Teams(client); 28 | const users = new sdk.Users(client); 29 | 30 | if ( 31 | !req.variables['APPWRITE_FUNCTION_ENDPOINT'] || 32 | !req.variables['APPWRITE_FUNCTION_API_KEY'] 33 | ) { 34 | console.warn("Environment variables are not set. Function cannot use Appwrite SDK."); 35 | } else { 36 | client 37 | .setEndpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT']) 38 | .setProject(req.variables['APPWRITE_FUNCTION_PROJECT_ID']) 39 | .setKey(req.variables['APPWRITE_FUNCTION_API_KEY']) 40 | .setSelfSigned(true); 41 | } 42 | 43 | res.json({ 44 | areDevelopersAwesome: true, 45 | }); 46 | }; 47 | -------------------------------------------------------------------------------- /node-18.0/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/node 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=node 4 | 5 | ### Node ### 6 | # Logs 7 | logs 8 | *.log 9 | npm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | lerna-debug.log* 13 | .pnpm-debug.log* 14 | 15 | # Diagnostic reports (https://nodejs.org/api/report.html) 16 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | *.pid.lock 23 | 24 | # Directory for instrumented libs generated by jscoverage/JSCover 25 | lib-cov 26 | 27 | # Coverage directory used by tools like istanbul 28 | coverage 29 | *.lcov 30 | 31 | # nyc test coverage 32 | .nyc_output 33 | 34 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 35 | .grunt 36 | 37 | # Bower dependency directory (https://bower.io/) 38 | bower_components 39 | 40 | # node-waf configuration 41 | .lock-wscript 42 | 43 | # Compiled binary addons (https://nodejs.org/api/addons.html) 44 | build/Release 45 | 46 | # Dependency directories 47 | node_modules/ 48 | jspm_packages/ 49 | 50 | # Snowpack dependency directory (https://snowpack.dev/) 51 | web_modules/ 52 | 53 | # TypeScript cache 54 | *.tsbuildinfo 55 | 56 | # Optional npm cache directory 57 | .npm 58 | 59 | # Optional eslint cache 60 | .eslintcache 61 | 62 | # Optional stylelint cache 63 | .stylelintcache 64 | 65 | # Microbundle cache 66 | .rpt2_cache/ 67 | .rts2_cache_cjs/ 68 | .rts2_cache_es/ 69 | .rts2_cache_umd/ 70 | 71 | # Optional REPL history 72 | .node_repl_history 73 | 74 | # Output of 'npm pack' 75 | *.tgz 76 | 77 | # Yarn Integrity file 78 | .yarn-integrity 79 | 80 | # dotenv environment variable files 81 | .env 82 | .env.development.local 83 | .env.test.local 84 | .env.production.local 85 | .env.local 86 | 87 | # parcel-bundler cache (https://parceljs.org/) 88 | .cache 89 | .parcel-cache 90 | 91 | # Next.js build output 92 | .next 93 | out 94 | 95 | # Nuxt.js build / generate output 96 | .nuxt 97 | dist 98 | 99 | # Gatsby files 100 | .cache/ 101 | # Comment in the public line in if your project uses Gatsby and not Next.js 102 | # https://nextjs.org/blog/next-9-1#public-directory-support 103 | # public 104 | 105 | # vuepress build output 106 | .vuepress/dist 107 | 108 | # vuepress v2.x temp and cache directory 109 | .temp 110 | 111 | # Docusaurus cache and generated files 112 | .docusaurus 113 | 114 | # Serverless directories 115 | .serverless/ 116 | 117 | # FuseBox cache 118 | .fusebox/ 119 | 120 | # DynamoDB Local files 121 | .dynamodb/ 122 | 123 | # TernJS port file 124 | .tern-port 125 | 126 | # Stores VSCode versions used for testing VSCode extensions 127 | .vscode-test 128 | 129 | # yarn v2 130 | .yarn/cache 131 | .yarn/unplugged 132 | .yarn/build-state.yml 133 | .yarn/install-state.gz 134 | .pnp.* 135 | 136 | ### Node Patch ### 137 | # Serverless Webpack directories 138 | .webpack/ 139 | 140 | # Optional stylelint cache 141 | 142 | # SvelteKit build / generate output 143 | .svelte-kit 144 | 145 | # End of https://www.toptal.com/developers/gitignore/api/node 146 | 147 | # OS 148 | ## Mac 149 | .DS_Store 150 | -------------------------------------------------------------------------------- /node-18.0/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/index.js`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /node-18.0/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "appwrite-function", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "node-appwrite": "^8.0.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /node-18.0/src/index.js: -------------------------------------------------------------------------------- 1 | const sdk = require("node-appwrite"); 2 | 3 | /* 4 | 'req' variable has: 5 | 'headers' - object with request headers 6 | 'payload' - request body data as a string 7 | 'variables' - object with function variables 8 | 9 | 'res' variable has: 10 | 'send(text, status)' - function to return text response. Status code defaults to 200 11 | 'json(obj, status)' - function to return JSON response. Status code defaults to 200 12 | 13 | If an error is thrown, a response with code 500 will be returned. 14 | */ 15 | 16 | module.exports = async function (req, res) { 17 | const client = new sdk.Client(); 18 | 19 | // You can remove services you don't use 20 | const account = new sdk.Account(client); 21 | const avatars = new sdk.Avatars(client); 22 | const database = new sdk.Databases(client); 23 | const functions = new sdk.Functions(client); 24 | const health = new sdk.Health(client); 25 | const locale = new sdk.Locale(client); 26 | const storage = new sdk.Storage(client); 27 | const teams = new sdk.Teams(client); 28 | const users = new sdk.Users(client); 29 | 30 | if ( 31 | !req.variables['APPWRITE_FUNCTION_ENDPOINT'] || 32 | !req.variables['APPWRITE_FUNCTION_API_KEY'] 33 | ) { 34 | console.warn("Environment variables are not set. Function cannot use Appwrite SDK."); 35 | } else { 36 | client 37 | .setEndpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT']) 38 | .setProject(req.variables['APPWRITE_FUNCTION_PROJECT_ID']) 39 | .setKey(req.variables['APPWRITE_FUNCTION_API_KEY']) 40 | .setSelfSigned(true); 41 | } 42 | 43 | res.json({ 44 | areDevelopersAwesome: true, 45 | }); 46 | }; 47 | -------------------------------------------------------------------------------- /php-8.0/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/composer 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=composer 4 | 5 | ### Composer ### 6 | composer.phar 7 | /vendor/ 8 | 9 | # Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control 10 | # You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file 11 | # composer.lock 12 | 13 | # End of https://www.toptal.com/developers/gitignore/api/composer 14 | 15 | # OS 16 | ## Mac 17 | .DS_Store 18 | -------------------------------------------------------------------------------- /php-8.0/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/index.php`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /php-8.0/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "user/function", 3 | "description": "", 4 | "type": "library", 5 | "license": "ISC", 6 | "authors": [], 7 | "require": { 8 | "php": ">=8.0.0", 9 | "appwrite/appwrite": "7.0.*" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /php-8.0/src/index.php: -------------------------------------------------------------------------------- 1 | setEndpoint($req['variables']['APPWRITE_FUNCTION_ENDPOINT']) 50 | ->setProject($req['variables']['APPWRITE_FUNCTION_PROJECT_ID']) 51 | ->setKey($req['variables']['APPWRITE_FUNCTION_API_KEY']) 52 | ->setSelfSigned(true); 53 | } 54 | 55 | $res->json([ 56 | 'areDevelopersAwesome' => true 57 | ]); 58 | }; -------------------------------------------------------------------------------- /php-8.1/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/composer 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=composer 4 | 5 | ### Composer ### 6 | composer.phar 7 | /vendor/ 8 | 9 | # Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control 10 | # You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file 11 | # composer.lock 12 | 13 | # End of https://www.toptal.com/developers/gitignore/api/composer 14 | 15 | # OS 16 | ## Mac 17 | .DS_Store 18 | -------------------------------------------------------------------------------- /php-8.1/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/index.php`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /php-8.1/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "user/function", 3 | "description": "", 4 | "type": "library", 5 | "license": "ISC", 6 | "authors": [], 7 | "require": { 8 | "php": ">=8.0.0", 9 | "appwrite/appwrite": "7.0.*" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /php-8.1/src/index.php: -------------------------------------------------------------------------------- 1 | setEndpoint($req['variables']['APPWRITE_FUNCTION_ENDPOINT']) 50 | ->setProject($req['variables']['APPWRITE_FUNCTION_PROJECT_ID']) 51 | ->setKey($req['variables']['APPWRITE_FUNCTION_API_KEY']) 52 | ->setSelfSigned(true); 53 | } 54 | 55 | $res->json([ 56 | 'areDevelopersAwesome' => true 57 | ]); 58 | }; -------------------------------------------------------------------------------- /python-3.10/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/python 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=python 4 | 5 | ### Python ### 6 | # Byte-compiled / optimized / DLL files 7 | __pycache__/ 8 | *.py[cod] 9 | *$py.class 10 | 11 | # C extensions 12 | *.so 13 | 14 | # Distribution / packaging 15 | .Python 16 | build/ 17 | develop-eggs/ 18 | dist/ 19 | downloads/ 20 | eggs/ 21 | .eggs/ 22 | lib/ 23 | lib64/ 24 | parts/ 25 | sdist/ 26 | var/ 27 | wheels/ 28 | share/python-wheels/ 29 | *.egg-info/ 30 | .installed.cfg 31 | *.egg 32 | MANIFEST 33 | 34 | # PyInstaller 35 | # Usually these files are written by a python script from a template 36 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 37 | *.manifest 38 | *.spec 39 | 40 | # Installer logs 41 | pip-log.txt 42 | pip-delete-this-directory.txt 43 | 44 | # Unit test / coverage reports 45 | htmlcov/ 46 | .tox/ 47 | .nox/ 48 | .coverage 49 | .coverage.* 50 | .cache 51 | nosetests.xml 52 | coverage.xml 53 | *.cover 54 | *.py,cover 55 | .hypothesis/ 56 | .pytest_cache/ 57 | cover/ 58 | 59 | # Translations 60 | *.mo 61 | *.pot 62 | 63 | # Django stuff: 64 | *.log 65 | local_settings.py 66 | db.sqlite3 67 | db.sqlite3-journal 68 | 69 | # Flask stuff: 70 | instance/ 71 | .webassets-cache 72 | 73 | # Scrapy stuff: 74 | .scrapy 75 | 76 | # Sphinx documentation 77 | docs/_build/ 78 | 79 | # PyBuilder 80 | .pybuilder/ 81 | target/ 82 | 83 | # Jupyter Notebook 84 | .ipynb_checkpoints 85 | 86 | # IPython 87 | profile_default/ 88 | ipython_config.py 89 | 90 | # pyenv 91 | # For a library or package, you might want to ignore these files since the code is 92 | # intended to run in multiple environments; otherwise, check them in: 93 | # .python-version 94 | 95 | # pipenv 96 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 97 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 98 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 99 | # install all needed dependencies. 100 | #Pipfile.lock 101 | 102 | # poetry 103 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 104 | # This is especially recommended for binary packages to ensure reproducibility, and is more 105 | # commonly ignored for libraries. 106 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 107 | #poetry.lock 108 | 109 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 110 | __pypackages__/ 111 | 112 | # Celery stuff 113 | celerybeat-schedule 114 | celerybeat.pid 115 | 116 | # SageMath parsed files 117 | *.sage.py 118 | 119 | # Environments 120 | .env 121 | .venv 122 | env/ 123 | venv/ 124 | ENV/ 125 | env.bak/ 126 | venv.bak/ 127 | 128 | # Spyder project settings 129 | .spyderproject 130 | .spyproject 131 | 132 | # Rope project settings 133 | .ropeproject 134 | 135 | # mkdocs documentation 136 | /site 137 | 138 | # mypy 139 | .mypy_cache/ 140 | .dmypy.json 141 | dmypy.json 142 | 143 | # Pyre type checker 144 | .pyre/ 145 | 146 | # pytype static type analyzer 147 | .pytype/ 148 | 149 | # Cython debug symbols 150 | cython_debug/ 151 | 152 | # PyCharm 153 | # JetBrains specific template is maintainted in a separate JetBrains.gitignore that can 154 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 155 | # and can be added to the global gitignore or merged into this file. For a more nuclear 156 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 157 | #.idea/ 158 | 159 | # End of https://www.toptal.com/developers/gitignore/api/python 160 | 161 | # OS 162 | ## Mac 163 | .DS_Store 164 | -------------------------------------------------------------------------------- /python-3.10/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/index.py`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /python-3.10/requirements.txt: -------------------------------------------------------------------------------- 1 | appwrite -------------------------------------------------------------------------------- /python-3.10/src/index.py: -------------------------------------------------------------------------------- 1 | from appwrite.client import Client 2 | 3 | # You can remove imports of services you don't use 4 | from appwrite.services.account import Account 5 | from appwrite.services.avatars import Avatars 6 | from appwrite.services.databases import Databases 7 | from appwrite.services.functions import Functions 8 | from appwrite.services.health import Health 9 | from appwrite.services.locale import Locale 10 | from appwrite.services.storage import Storage 11 | from appwrite.services.teams import Teams 12 | from appwrite.services.users import Users 13 | 14 | """ 15 | 'req' variable has: 16 | 'headers' - object with request headers 17 | 'payload' - request body data as a string 18 | 'variables' - object with function variables 19 | 20 | 'res' variable has: 21 | 'send(text, status)' - function to return text response. Status code defaults to 200 22 | 'json(obj, status)' - function to return JSON response. Status code defaults to 200 23 | 24 | If an error is thrown, a response with code 500 will be returned. 25 | """ 26 | 27 | def main(req, res): 28 | client = Client() 29 | 30 | # You can remove services you don't use 31 | account = Account(client) 32 | avatars = Avatars(client) 33 | database = Databases(client) 34 | functions = Functions(client) 35 | health = Health(client) 36 | locale = Locale(client) 37 | storage = Storage(client) 38 | teams = Teams(client) 39 | users = Users(client) 40 | 41 | if not req.variables.get('APPWRITE_FUNCTION_ENDPOINT') or not req.variables.get('APPWRITE_FUNCTION_API_KEY'): 42 | print('Environment variables are not set. Function cannot use Appwrite SDK.') 43 | else: 44 | ( 45 | client 46 | .set_endpoint(req.variables.get('APPWRITE_FUNCTION_ENDPOINT', None)) 47 | .set_project(req.variables.get('APPWRITE_FUNCTION_PROJECT_ID', None)) 48 | .set_key(req.variables.get('APPWRITE_FUNCTION_API_KEY', None)) 49 | .set_self_signed(True) 50 | ) 51 | 52 | return res.json({ 53 | "areDevelopersAwesome": True, 54 | }) 55 | -------------------------------------------------------------------------------- /python-3.8/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/python 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=python 4 | 5 | ### Python ### 6 | # Byte-compiled / optimized / DLL files 7 | __pycache__/ 8 | *.py[cod] 9 | *$py.class 10 | 11 | # C extensions 12 | *.so 13 | 14 | # Distribution / packaging 15 | .Python 16 | build/ 17 | develop-eggs/ 18 | dist/ 19 | downloads/ 20 | eggs/ 21 | .eggs/ 22 | lib/ 23 | lib64/ 24 | parts/ 25 | sdist/ 26 | var/ 27 | wheels/ 28 | share/python-wheels/ 29 | *.egg-info/ 30 | .installed.cfg 31 | *.egg 32 | MANIFEST 33 | 34 | # PyInstaller 35 | # Usually these files are written by a python script from a template 36 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 37 | *.manifest 38 | *.spec 39 | 40 | # Installer logs 41 | pip-log.txt 42 | pip-delete-this-directory.txt 43 | 44 | # Unit test / coverage reports 45 | htmlcov/ 46 | .tox/ 47 | .nox/ 48 | .coverage 49 | .coverage.* 50 | .cache 51 | nosetests.xml 52 | coverage.xml 53 | *.cover 54 | *.py,cover 55 | .hypothesis/ 56 | .pytest_cache/ 57 | cover/ 58 | 59 | # Translations 60 | *.mo 61 | *.pot 62 | 63 | # Django stuff: 64 | *.log 65 | local_settings.py 66 | db.sqlite3 67 | db.sqlite3-journal 68 | 69 | # Flask stuff: 70 | instance/ 71 | .webassets-cache 72 | 73 | # Scrapy stuff: 74 | .scrapy 75 | 76 | # Sphinx documentation 77 | docs/_build/ 78 | 79 | # PyBuilder 80 | .pybuilder/ 81 | target/ 82 | 83 | # Jupyter Notebook 84 | .ipynb_checkpoints 85 | 86 | # IPython 87 | profile_default/ 88 | ipython_config.py 89 | 90 | # pyenv 91 | # For a library or package, you might want to ignore these files since the code is 92 | # intended to run in multiple environments; otherwise, check them in: 93 | # .python-version 94 | 95 | # pipenv 96 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 97 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 98 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 99 | # install all needed dependencies. 100 | #Pipfile.lock 101 | 102 | # poetry 103 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 104 | # This is especially recommended for binary packages to ensure reproducibility, and is more 105 | # commonly ignored for libraries. 106 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 107 | #poetry.lock 108 | 109 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 110 | __pypackages__/ 111 | 112 | # Celery stuff 113 | celerybeat-schedule 114 | celerybeat.pid 115 | 116 | # SageMath parsed files 117 | *.sage.py 118 | 119 | # Environments 120 | .env 121 | .venv 122 | env/ 123 | venv/ 124 | ENV/ 125 | env.bak/ 126 | venv.bak/ 127 | 128 | # Spyder project settings 129 | .spyderproject 130 | .spyproject 131 | 132 | # Rope project settings 133 | .ropeproject 134 | 135 | # mkdocs documentation 136 | /site 137 | 138 | # mypy 139 | .mypy_cache/ 140 | .dmypy.json 141 | dmypy.json 142 | 143 | # Pyre type checker 144 | .pyre/ 145 | 146 | # pytype static type analyzer 147 | .pytype/ 148 | 149 | # Cython debug symbols 150 | cython_debug/ 151 | 152 | # PyCharm 153 | # JetBrains specific template is maintainted in a separate JetBrains.gitignore that can 154 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 155 | # and can be added to the global gitignore or merged into this file. For a more nuclear 156 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 157 | #.idea/ 158 | 159 | # End of https://www.toptal.com/developers/gitignore/api/python 160 | 161 | # OS 162 | ## Mac 163 | .DS_Store 164 | -------------------------------------------------------------------------------- /python-3.8/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/index.py`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /python-3.8/requirements.txt: -------------------------------------------------------------------------------- 1 | appwrite -------------------------------------------------------------------------------- /python-3.8/src/index.py: -------------------------------------------------------------------------------- 1 | from appwrite.client import Client 2 | 3 | # You can remove imports of services you don't use 4 | from appwrite.services.account import Account 5 | from appwrite.services.avatars import Avatars 6 | from appwrite.services.databases import Databases 7 | from appwrite.services.functions import Functions 8 | from appwrite.services.health import Health 9 | from appwrite.services.locale import Locale 10 | from appwrite.services.storage import Storage 11 | from appwrite.services.teams import Teams 12 | from appwrite.services.users import Users 13 | 14 | """ 15 | 'req' variable has: 16 | 'headers' - object with request headers 17 | 'payload' - request body data as a string 18 | 'variables' - object with function variables 19 | 20 | 'res' variable has: 21 | 'send(text, status)' - function to return text response. Status code defaults to 200 22 | 'json(obj, status)' - function to return JSON response. Status code defaults to 200 23 | 24 | If an error is thrown, a response with code 500 will be returned. 25 | """ 26 | 27 | def main(req, res): 28 | client = Client() 29 | 30 | # You can remove services you don't use 31 | account = Account(client) 32 | avatars = Avatars(client) 33 | database = Databases(client) 34 | functions = Functions(client) 35 | health = Health(client) 36 | locale = Locale(client) 37 | storage = Storage(client) 38 | teams = Teams(client) 39 | users = Users(client) 40 | 41 | if not req.variables.get('APPWRITE_FUNCTION_ENDPOINT') or not req.variables.get('APPWRITE_FUNCTION_API_KEY'): 42 | print('Environment variables are not set. Function cannot use Appwrite SDK.') 43 | else: 44 | ( 45 | client 46 | .set_endpoint(req.variables.get('APPWRITE_FUNCTION_ENDPOINT', None)) 47 | .set_project(req.variables.get('APPWRITE_FUNCTION_PROJECT_ID', None)) 48 | .set_key(req.variables.get('APPWRITE_FUNCTION_API_KEY', None)) 49 | .set_self_signed(True) 50 | ) 51 | 52 | return res.json({ 53 | "areDevelopersAwesome": True, 54 | }) -------------------------------------------------------------------------------- /python-3.9/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/python 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=python 4 | 5 | ### Python ### 6 | # Byte-compiled / optimized / DLL files 7 | __pycache__/ 8 | *.py[cod] 9 | *$py.class 10 | 11 | # C extensions 12 | *.so 13 | 14 | # Distribution / packaging 15 | .Python 16 | build/ 17 | develop-eggs/ 18 | dist/ 19 | downloads/ 20 | eggs/ 21 | .eggs/ 22 | lib/ 23 | lib64/ 24 | parts/ 25 | sdist/ 26 | var/ 27 | wheels/ 28 | share/python-wheels/ 29 | *.egg-info/ 30 | .installed.cfg 31 | *.egg 32 | MANIFEST 33 | 34 | # PyInstaller 35 | # Usually these files are written by a python script from a template 36 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 37 | *.manifest 38 | *.spec 39 | 40 | # Installer logs 41 | pip-log.txt 42 | pip-delete-this-directory.txt 43 | 44 | # Unit test / coverage reports 45 | htmlcov/ 46 | .tox/ 47 | .nox/ 48 | .coverage 49 | .coverage.* 50 | .cache 51 | nosetests.xml 52 | coverage.xml 53 | *.cover 54 | *.py,cover 55 | .hypothesis/ 56 | .pytest_cache/ 57 | cover/ 58 | 59 | # Translations 60 | *.mo 61 | *.pot 62 | 63 | # Django stuff: 64 | *.log 65 | local_settings.py 66 | db.sqlite3 67 | db.sqlite3-journal 68 | 69 | # Flask stuff: 70 | instance/ 71 | .webassets-cache 72 | 73 | # Scrapy stuff: 74 | .scrapy 75 | 76 | # Sphinx documentation 77 | docs/_build/ 78 | 79 | # PyBuilder 80 | .pybuilder/ 81 | target/ 82 | 83 | # Jupyter Notebook 84 | .ipynb_checkpoints 85 | 86 | # IPython 87 | profile_default/ 88 | ipython_config.py 89 | 90 | # pyenv 91 | # For a library or package, you might want to ignore these files since the code is 92 | # intended to run in multiple environments; otherwise, check them in: 93 | # .python-version 94 | 95 | # pipenv 96 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 97 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 98 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 99 | # install all needed dependencies. 100 | #Pipfile.lock 101 | 102 | # poetry 103 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 104 | # This is especially recommended for binary packages to ensure reproducibility, and is more 105 | # commonly ignored for libraries. 106 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 107 | #poetry.lock 108 | 109 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 110 | __pypackages__/ 111 | 112 | # Celery stuff 113 | celerybeat-schedule 114 | celerybeat.pid 115 | 116 | # SageMath parsed files 117 | *.sage.py 118 | 119 | # Environments 120 | .env 121 | .venv 122 | env/ 123 | venv/ 124 | ENV/ 125 | env.bak/ 126 | venv.bak/ 127 | 128 | # Spyder project settings 129 | .spyderproject 130 | .spyproject 131 | 132 | # Rope project settings 133 | .ropeproject 134 | 135 | # mkdocs documentation 136 | /site 137 | 138 | # mypy 139 | .mypy_cache/ 140 | .dmypy.json 141 | dmypy.json 142 | 143 | # Pyre type checker 144 | .pyre/ 145 | 146 | # pytype static type analyzer 147 | .pytype/ 148 | 149 | # Cython debug symbols 150 | cython_debug/ 151 | 152 | # PyCharm 153 | # JetBrains specific template is maintainted in a separate JetBrains.gitignore that can 154 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 155 | # and can be added to the global gitignore or merged into this file. For a more nuclear 156 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 157 | #.idea/ 158 | 159 | # End of https://www.toptal.com/developers/gitignore/api/python 160 | 161 | # OS 162 | ## Mac 163 | .DS_Store 164 | -------------------------------------------------------------------------------- /python-3.9/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/index.py`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /python-3.9/requirements.txt: -------------------------------------------------------------------------------- 1 | appwrite -------------------------------------------------------------------------------- /python-3.9/src/index.py: -------------------------------------------------------------------------------- 1 | from appwrite.client import Client 2 | 3 | # You can remove imports of services you don't use 4 | from appwrite.services.account import Account 5 | from appwrite.services.avatars import Avatars 6 | from appwrite.services.databases import Databases 7 | from appwrite.services.functions import Functions 8 | from appwrite.services.health import Health 9 | from appwrite.services.locale import Locale 10 | from appwrite.services.storage import Storage 11 | from appwrite.services.teams import Teams 12 | from appwrite.services.users import Users 13 | 14 | """ 15 | 'req' variable has: 16 | 'headers' - object with request headers 17 | 'payload' - request body data as a string 18 | 'variables' - object with function variables 19 | 20 | 'res' variable has: 21 | 'send(text, status)' - function to return text response. Status code defaults to 200 22 | 'json(obj, status)' - function to return JSON response. Status code defaults to 200 23 | 24 | If an error is thrown, a response with code 500 will be returned. 25 | """ 26 | 27 | def main(req, res): 28 | client = Client() 29 | 30 | # You can remove services you don't use 31 | account = Account(client) 32 | avatars = Avatars(client) 33 | database = Databases(client) 34 | functions = Functions(client) 35 | health = Health(client) 36 | locale = Locale(client) 37 | storage = Storage(client) 38 | teams = Teams(client) 39 | users = Users(client) 40 | 41 | if not req.variables.get('APPWRITE_FUNCTION_ENDPOINT') or not req.variables.get('APPWRITE_FUNCTION_API_KEY'): 42 | print('Environment variables are not set. Function cannot use Appwrite SDK.') 43 | else: 44 | ( 45 | client 46 | .set_endpoint(req.variables.get('APPWRITE_FUNCTION_ENDPOINT', None)) 47 | .set_project(req.variables.get('APPWRITE_FUNCTION_PROJECT_ID', None)) 48 | .set_key(req.variables.get('APPWRITE_FUNCTION_API_KEY', None)) 49 | .set_self_signed(True) 50 | ) 51 | 52 | return res.json({ 53 | "areDevelopersAwesome": True, 54 | }) -------------------------------------------------------------------------------- /ruby-3.0/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/ruby 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=ruby 4 | 5 | ### Ruby ### 6 | *.gem 7 | *.rbc 8 | /.config 9 | /coverage/ 10 | /InstalledFiles 11 | /pkg/ 12 | /spec/reports/ 13 | /spec/examples.txt 14 | /test/tmp/ 15 | /test/version_tmp/ 16 | /tmp/ 17 | 18 | # Used by dotenv library to load environment variables. 19 | # .env 20 | 21 | # Ignore Byebug command history file. 22 | .byebug_history 23 | 24 | ## Specific to RubyMotion: 25 | .dat* 26 | .repl_history 27 | build/ 28 | *.bridgesupport 29 | build-iPhoneOS/ 30 | build-iPhoneSimulator/ 31 | 32 | ## Specific to RubyMotion (use of CocoaPods): 33 | # 34 | # We recommend against adding the Pods directory to your .gitignore. However 35 | # you should judge for yourself, the pros and cons are mentioned at: 36 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 37 | # vendor/Pods/ 38 | 39 | ## Documentation cache and generated files: 40 | /.yardoc/ 41 | /_yardoc/ 42 | /doc/ 43 | /rdoc/ 44 | 45 | ## Environment normalization: 46 | /.bundle/ 47 | /vendor/bundle 48 | /lib/bundler/man/ 49 | 50 | # for a library or gem, you might want to ignore these files since the code is 51 | # intended to run in multiple environments; otherwise, check them in: 52 | # Gemfile.lock 53 | # .ruby-version 54 | # .ruby-gemset 55 | 56 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: 57 | .rvmrc 58 | 59 | # Used by RuboCop. Remote config files pulled in from inherit_from directive. 60 | # .rubocop-https?--* 61 | 62 | # End of https://www.toptal.com/developers/gitignore/api/ruby 63 | 64 | # OS 65 | ## Mac 66 | .DS_Store 67 | -------------------------------------------------------------------------------- /ruby-3.0/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem 'appwrite' -------------------------------------------------------------------------------- /ruby-3.0/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/index.rb`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /ruby-3.0/src/index.rb: -------------------------------------------------------------------------------- 1 | require 'appwrite' 2 | 3 | =begin 4 | 'req' variable has: 5 | 'headers' - object with request headers 6 | 'payload' - request body data as a string 7 | 'variables' - object with function variables 8 | 9 | 'res' variable has: 10 | 'send(text, status)' - function to return text response. Status code defaults to 200 11 | 'json(obj, status)' - function to return JSON response. Status code defaults to 200 12 | 13 | If an error is thrown, a response with code 500 will be returned. 14 | =end 15 | 16 | def main(req, res) 17 | client = Appwrite::Client.new 18 | 19 | # You can remove services you don't use 20 | account = Appwrite::Account.new(client) 21 | avatars = Appwrite::Avatars.new(client) 22 | database = Appwrite::Databases.new(client) 23 | functions = Appwrite::Functions.new(client) 24 | health = Appwrite::Health.new(client) 25 | locale = Appwrite::Locale.new(client) 26 | storage = Appwrite::Storage.new(client) 27 | teams = Appwrite::Teams.new(client) 28 | users = Appwrite::Users.new(client) 29 | 30 | if !req.variables['APPWRITE_FUNCTION_ENDPOINT'] or !req.variables['APPWRITE_FUNCTION_API_KEY'] 31 | puts "Environment variables are not set. Function cannot use Appwrite SDK." 32 | else 33 | client 34 | .set_endpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT']) 35 | .set_project(req.variables['APPWRITE_FUNCTION_PROJECTID']) 36 | .set_key(req.variables['APPWRITE_FUNCTION_API_KEY']) 37 | .set_self_signed(true) 38 | end 39 | 40 | return res.json({ 41 | :areDevelopersAwesome => true, 42 | }) 43 | end -------------------------------------------------------------------------------- /ruby-3.1/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/ruby 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=ruby 4 | 5 | ### Ruby ### 6 | *.gem 7 | *.rbc 8 | /.config 9 | /coverage/ 10 | /InstalledFiles 11 | /pkg/ 12 | /spec/reports/ 13 | /spec/examples.txt 14 | /test/tmp/ 15 | /test/version_tmp/ 16 | /tmp/ 17 | 18 | # Used by dotenv library to load environment variables. 19 | # .env 20 | 21 | # Ignore Byebug command history file. 22 | .byebug_history 23 | 24 | ## Specific to RubyMotion: 25 | .dat* 26 | .repl_history 27 | build/ 28 | *.bridgesupport 29 | build-iPhoneOS/ 30 | build-iPhoneSimulator/ 31 | 32 | ## Specific to RubyMotion (use of CocoaPods): 33 | # 34 | # We recommend against adding the Pods directory to your .gitignore. However 35 | # you should judge for yourself, the pros and cons are mentioned at: 36 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 37 | # vendor/Pods/ 38 | 39 | ## Documentation cache and generated files: 40 | /.yardoc/ 41 | /_yardoc/ 42 | /doc/ 43 | /rdoc/ 44 | 45 | ## Environment normalization: 46 | /.bundle/ 47 | /vendor/bundle 48 | /lib/bundler/man/ 49 | 50 | # for a library or gem, you might want to ignore these files since the code is 51 | # intended to run in multiple environments; otherwise, check them in: 52 | # Gemfile.lock 53 | # .ruby-version 54 | # .ruby-gemset 55 | 56 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: 57 | .rvmrc 58 | 59 | # Used by RuboCop. Remote config files pulled in from inherit_from directive. 60 | # .rubocop-https?--* 61 | 62 | # End of https://www.toptal.com/developers/gitignore/api/ruby 63 | 64 | # OS 65 | ## Mac 66 | .DS_Store 67 | -------------------------------------------------------------------------------- /ruby-3.1/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem 'appwrite' -------------------------------------------------------------------------------- /ruby-3.1/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project 34 | - **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key 35 | 36 | 37 | ## 🚀 Deployment 38 | 39 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 40 | 41 | ### Using CLI 42 | 43 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 44 | 45 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 46 | 47 | ### Manual using tar.gz 48 | 49 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/index.rb`, and upload the file we just generated. 50 | -------------------------------------------------------------------------------- /ruby-3.1/src/index.rb: -------------------------------------------------------------------------------- 1 | require 'appwrite' 2 | 3 | =begin 4 | 'req' variable has: 5 | 'headers' - object with request headers 6 | 'payload' - request body data as a string 7 | 'variables' - object with function variables 8 | 9 | 'res' variable has: 10 | 'send(text, status)' - function to return text response. Status code defaults to 200 11 | 'json(obj, status)' - function to return JSON response. Status code defaults to 200 12 | 13 | If an error is thrown, a response with code 500 will be returned. 14 | =end 15 | 16 | def main(req, res) 17 | client = Appwrite::Client.new 18 | 19 | # You can remove services you don't use 20 | account = Appwrite::Account.new(client) 21 | avatars = Appwrite::Avatars.new(client) 22 | database = Appwrite::Databases.new(client) 23 | functions = Appwrite::Functions.new(client) 24 | health = Appwrite::Health.new(client) 25 | locale = Appwrite::Locale.new(client) 26 | storage = Appwrite::Storage.new(client) 27 | teams = Appwrite::Teams.new(client) 28 | users = Appwrite::Users.new(client) 29 | 30 | if !req.variables['APPWRITE_FUNCTION_ENDPOINT'] or !req.variables['APPWRITE_FUNCTION_API_KEY'] 31 | puts "Environment variables are not set. Function cannot use Appwrite SDK." 32 | else 33 | client 34 | .set_endpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT']) 35 | .set_project(req.variables['APPWRITE_FUNCTION_PROJECTID']) 36 | .set_key(req.variables['APPWRITE_FUNCTION_API_KEY']) 37 | .set_self_signed(true) 38 | end 39 | 40 | return res.json({ 41 | :areDevelopersAwesome => true, 42 | }) 43 | end -------------------------------------------------------------------------------- /rust-1.55/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/rust 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=rust 4 | 5 | ### Rust ### 6 | # Generated by Cargo 7 | # will have compiled files and executables 8 | debug/ 9 | target/ 10 | 11 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 12 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html 13 | Cargo.lock 14 | 15 | # These are backup files generated by rustfmt 16 | **/*.rs.bk 17 | 18 | # MSVC Windows builds of rustc generate these, which store debugging information 19 | *.pdb 20 | 21 | # End of https://www.toptal.com/developers/gitignore/api/rust 22 | 23 | # OS 24 | ## Mac 25 | .DS_Store 26 | -------------------------------------------------------------------------------- /rust-1.55/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - No special environment variables are required for the cloud function. 34 | 35 | ## 🚀 Deployment 36 | 37 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 38 | 39 | ### Using CLI 40 | 41 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 42 | 43 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 44 | 45 | ### Manual using tar.gz 46 | 47 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `main.rs`, and upload the file we just generated. 48 | -------------------------------------------------------------------------------- /rust-1.55/main.rs: -------------------------------------------------------------------------------- 1 | 2 | use super::{Response, RequestValue}; 3 | 4 | // json! is a useful macro for converting json into the Serde Json type (https://docs.rs/rocket/0.5.0-rc.1/rocket/serde/json/enum.Value.html). 5 | use rocket::serde::json::json; 6 | 7 | /* 8 | 'Value' is rocket::serde::json::Value. and the docs of it can be found here: https://docs.rs/rocket/0.5.0-rc.1/rocket/serde/json/enum.Value.html 9 | 10 | 'req' is a struct `RequestValue` that can be imported from super which contains the following: 11 | 'headers' - object with request headers - "Option>" 12 | 'payload' - request body data as a string - "String" 13 | 'variables' - object with function variables - "Map" 14 | 'res' is a enum `Response` that can be imported from super which has the two following functions: 15 | 'send(value: String)' - function to return text response. 16 | 'json(value: Value)' - function to return JSON response. 17 | 18 | If an error is thrown, a response with code 500 will be returned. 19 | */ 20 | pub fn main(req: RequestValue) -> Response { 21 | return Response::json( 22 | json!({ 23 | "areDevelopersAwesome": true 24 | }) 25 | ); 26 | } -------------------------------------------------------------------------------- /swift-5.5/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/swift 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=swift 4 | 5 | ### Swift ### 6 | # Xcode 7 | # 8 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 9 | 10 | ## User settings 11 | xcuserdata/ 12 | 13 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 14 | *.xcscmblueprint 15 | *.xccheckout 16 | 17 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 18 | build/ 19 | DerivedData/ 20 | *.moved-aside 21 | *.pbxuser 22 | !default.pbxuser 23 | *.mode1v3 24 | !default.mode1v3 25 | *.mode2v3 26 | !default.mode2v3 27 | *.perspectivev3 28 | !default.perspectivev3 29 | 30 | ## Obj-C/Swift specific 31 | *.hmap 32 | 33 | ## App packaging 34 | *.ipa 35 | *.dSYM.zip 36 | *.dSYM 37 | 38 | ## Playgrounds 39 | timeline.xctimeline 40 | playground.xcworkspace 41 | 42 | # Swift Package Manager 43 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 44 | # Packages/ 45 | # Package.pins 46 | # Package.resolved 47 | # *.xcodeproj 48 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 49 | # hence it is not needed unless you have added a package configuration file to your project 50 | # .swiftpm 51 | 52 | .build/ 53 | 54 | # CocoaPods 55 | # We recommend against adding the Pods directory to your .gitignore. However 56 | # you should judge for yourself, the pros and cons are mentioned at: 57 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 58 | # Pods/ 59 | # Add this line if you want to avoid checking in source code from the Xcode workspace 60 | # *.xcworkspace 61 | 62 | # Carthage 63 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 64 | # Carthage/Checkouts 65 | 66 | Carthage/Build/ 67 | 68 | # Accio dependency management 69 | Dependencies/ 70 | .accio/ 71 | 72 | # fastlane 73 | # It is recommended to not store the screenshots in the git repo. 74 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 75 | # For more information about the recommended setup visit: 76 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 77 | 78 | fastlane/report.xml 79 | fastlane/Preview.html 80 | fastlane/screenshots/**/*.png 81 | fastlane/test_output 82 | 83 | # Code Injection 84 | # After new code Injection tools there's a generated folder /iOSInjectionProject 85 | # https://github.com/johnno1962/injectionforxcode 86 | 87 | iOSInjectionProject/ 88 | 89 | # End of https://www.toptal.com/developers/gitignore/api/swift 90 | 91 | # OS 92 | ## Mac 93 | .DS_Store 94 | -------------------------------------------------------------------------------- /swift-5.5/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.5 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "swift-5.5", 8 | dependencies: [ 9 | // Dependencies declare other packages that this package depends on. 10 | // .package(url: /* package url */, from: "1.0.0"), 11 | .package(url: "https://github.com/appwrite/sdk-for-swift", .upToNextMajor(from: "1.0.0")), 12 | ], 13 | targets: [ 14 | // Targets are the basic building blocks of a package. A target can define a module or a test suite. 15 | // Targets can depend on other targets in this package, and on products in packages this package depends on. 16 | .executableTarget( 17 | name: "swift-5.5", 18 | dependencies: [ 19 | .product(name: "Appwrite", package: "sdk-for-swift") 20 | ]), 21 | ] 22 | ) 23 | -------------------------------------------------------------------------------- /swift-5.5/README.md: -------------------------------------------------------------------------------- 1 | # 📧 Unnamed function 2 | 3 | 4 | 5 | Welcome to the documentation of this function 👋 We strongly recommend keeping this file in sync with your function's logic to make sure anyone can easily understand your function in the future. If you don't need documentation, you can remove this file. 6 | 7 | ## 🤖 Documentation 8 | 9 | Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. 10 | 11 | 12 | 13 | _Example input:_ 14 | 15 | This function expects no input 16 | 17 | 18 | 19 | _Example output:_ 20 | 21 | 22 | 23 | ```json 24 | { 25 | "areDevelopersAwesome": true 26 | } 27 | ``` 28 | 29 | ## 📝 Environment Variables 30 | 31 | List of environment variables used by this cloud function: 32 | 33 | - No special environment variables are required for the cloud function. 34 | 35 | ## 🚀 Deployment 36 | 37 | There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience. 38 | 39 | ### Using CLI 40 | 41 | Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. 42 | 43 | Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy. 44 | 45 | ### Manual using tar.gz 46 | 47 | Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `Surces/swift-5.5/main.swift`, and upload the file we just generated. 48 | -------------------------------------------------------------------------------- /swift-5.5/Sources/index.swift: -------------------------------------------------------------------------------- 1 | import Appwrite 2 | import AppwriteModels 3 | import Foundation 4 | 5 | /* 6 | 'req' variable has: 7 | 'headers' - object with request headers 8 | 'payload' - request body data as a string 9 | 'variables' - object with function variables 10 | 11 | 'res' variable has: 12 | 'send(text, status)' - function to return text response. Status code defaults to 200 13 | 'json(obj, status)' - function to return JSON response. Status code defaults to 200 14 | 15 | If an error is thrown, a response with code 500 will be returned. 16 | */ 17 | 18 | func main(req: RequestValue, res: RequestResponse) -> RequestResponse { 19 | let client = Client() 20 | 21 | // You can remove services you don't use 22 | let account = Account(client) 23 | let avatars = Avatars(client) 24 | let database = Databases(client) 25 | let functions = Functions(client) 26 | let health = Health(client) 27 | let locale = Locale(client) 28 | let storage = Storage(client) 29 | let teams = Teams(client) 30 | let users = Users(client) 31 | 32 | if (req.variables["APPWRITE_FUNCTION_ENDPOINT"] == nil || req.variables["APPWRITE_FUNCTION_API_KEY"] == nil) { 33 | print("Environment variables are not set. Function cannot use Appwrite SDK.") 34 | } else { 35 | client 36 | .setEndpoint(req.variables["APPWRITE_FUNCTION_ENDPOINT"]!) 37 | .setProject(req.variables["APPWRITE_FUNCTION_PROJECT_ID"]!) 38 | .setKey(req.variables["APPWRITE_FUNCTION_API_KEY"]!) 39 | } 40 | 41 | return res.json(data: [ 42 | "areDevelopersAwesome": true 43 | ]) 44 | } 45 | --------------------------------------------------------------------------------