From fb8ecba4873027a953772a2f1f32336b5c99bc96 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Thu, 20 Jul 2023 16:03:34 +0100 Subject: [PATCH 1/2] feat: Dart starter --- dart/starter-template/.gitignore | 27 ++++++++++++++++ {python => dart}/starter-template/README.md | 8 ++--- dart/starter-template/analysis_options.yaml | 1 + dart/starter-template/lib/main.dart | 34 +++++++++++++++++++++ dart/starter-template/pubspec.yaml | 11 +++++++ 5 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 dart/starter-template/.gitignore rename {python => dart}/starter-template/README.md (77%) create mode 100644 dart/starter-template/analysis_options.yaml create mode 100644 dart/starter-template/lib/main.dart create mode 100644 dart/starter-template/pubspec.yaml diff --git a/dart/starter-template/.gitignore b/dart/starter-template/.gitignore new file mode 100644 index 00000000..dc259f50 --- /dev/null +++ b/dart/starter-template/.gitignore @@ -0,0 +1,27 @@ +# See https://www.dartlang.org/guides/libraries/private-files + +# Files and directories created by pub +.dart_tool/ +.packages +build/ +# If you're building an application, you may want to check-in your pubspec.lock +pubspec.lock + +# Directory created by dartdoc +# If you don't generate documentation locally you can remove this line. +doc/api/ + +# dotenv environment variables file +.env* + +# Avoid committing generated Javascript files: +*.dart.js +*.info.json # Produced by the --dump-info flag. +*.js # When generated by dart2js. Don't specify *.js if your + # project includes source files written in JavaScript. +*.js_ +*.js.deps +*.js.map + +.flutter-plugins +.flutter-plugins-dependencies \ No newline at end of file diff --git a/python/starter-template/README.md b/dart/starter-template/README.md similarity index 77% rename from python/starter-template/README.md rename to dart/starter-template/README.md index 79678e49..874d7ae9 100644 --- a/python/starter-template/README.md +++ b/dart/starter-template/README.md @@ -1,6 +1,6 @@ -# ⚡ Python Starter Function +# ⚡ Dart Starter Function -A simple starter function. Edit `src/main.py` to get started and create something awesome! 🚀 +A simple starter function. Edit `lib/main.dart` to get started and create something awesome! 🚀 ## 🧰 Usage @@ -38,8 +38,8 @@ Sample `200` Response: | Setting | Value | |-------------------|-----------------------------------| | Runtime | Python (3.10) | -| Entrypoint | `src/main.py` | -| Build Commands | `pip install -r requirements.txt` | +| Entrypoint | `lib/main.dart` | +| Build Commands | `dart pub get` | | Permissions | `any` | | Timeout (Seconds) | 15 | diff --git a/dart/starter-template/analysis_options.yaml b/dart/starter-template/analysis_options.yaml new file mode 100644 index 00000000..ea2c9e94 --- /dev/null +++ b/dart/starter-template/analysis_options.yaml @@ -0,0 +1 @@ +include: package:lints/recommended.yaml \ No newline at end of file diff --git a/dart/starter-template/lib/main.dart b/dart/starter-template/lib/main.dart new file mode 100644 index 00000000..2142a167 --- /dev/null +++ b/dart/starter-template/lib/main.dart @@ -0,0 +1,34 @@ +import 'dart:async'; +import 'package:dart_appwrite/dart_appwrite.dart'; + +// This is your Appwrite function +// It's executed each time we get a request +Future main(final context) async { +// Why not try the Appwrite SDK? + // + // final client = Client() + // .setEndpoint('https://cloud.appwrite.io/v1') + // .setProject(process.env.APPWRITE_PROJECT_ID) + // .setKey(process.env.APPWRITE_API_KEY); + + // You can log messages to the console + context.log('Hello, Logs! 👋'); + + // If something goes wrong, log an error + context.error('Hello, Errors! ⛔'); + + // The `req` object contains the request data + if (context.req.method == 'GET') { + // Send a response with the res object helpers + // `res.send()` dispatches a string back to the client + return context.res.send('Hello, World! 🌎'); + } + + // `res.json()` is a handy helper for sending JSON + return context.res.json({ + 'motto': 'Build Fast. Scale Big. All in One Place.', + 'learn': 'https://appwrite.io/docs', + 'connect': 'https://appwrite.io/discord', + 'getInspired': 'https://builtwith.appwrite.io', + }); +} diff --git a/dart/starter-template/pubspec.yaml b/dart/starter-template/pubspec.yaml new file mode 100644 index 00000000..2f3e190c --- /dev/null +++ b/dart/starter-template/pubspec.yaml @@ -0,0 +1,11 @@ +name: starter_template +version: 1.0.0 + +environment: + sdk: ^3.1.0-edge.3daa47b54e5f39241c44858e0d66ce51723040bf + +dependencies: + dart_appwrite: ^8.0.1 + +dev_dependencies: + lints: ^2.0.0 From 20e2229f206048dd107d9218d7eeb36d785fc645 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 21 Jul 2023 12:03:27 +0100 Subject: [PATCH 2/2] chore: matej review --- dart/starter-template/README.md | 14 ++++----- python/starter-template/README.md | 48 +++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 python/starter-template/README.md diff --git a/dart/starter-template/README.md b/dart/starter-template/README.md index 874d7ae9..93966d48 100644 --- a/dart/starter-template/README.md +++ b/dart/starter-template/README.md @@ -35,13 +35,13 @@ Sample `200` Response: ## ⚙️ Configuration -| Setting | Value | -|-------------------|-----------------------------------| -| Runtime | Python (3.10) | -| Entrypoint | `lib/main.dart` | -| Build Commands | `dart pub get` | -| Permissions | `any` | -| Timeout (Seconds) | 15 | +| Setting | Value | +|-------------------|-----------------| +| Runtime | Dart (3.0) | +| Entrypoint | `lib/main.dart` | +| Build Commands | `dart pub get` | +| Permissions | `any` | +| Timeout (Seconds) | 15 | ## 🔒 Environment Variables diff --git a/python/starter-template/README.md b/python/starter-template/README.md new file mode 100644 index 00000000..79678e49 --- /dev/null +++ b/python/starter-template/README.md @@ -0,0 +1,48 @@ +# ⚡ Python Starter Function + +A simple starter function. Edit `src/main.py` to get started and create something awesome! 🚀 + +## 🧰 Usage + +### `GET` + +- Returns a "Hello, World!" message. + +**Response** + +Sample `200` Response: + +```text +Hello, World! 🌎 +``` + +### `POST`, `PUT`, `PATCH`, `DELETE` + +- Returns a "Learn More" JSON response. + +**Response** + +Sample `200` Response: + +```json +{ + "motto": "Build Fast. Scale Big. All in One Place.", + "learn": "https://appwrite.io/docs", + "connect": "https://appwrite.io/discord", + "getInspired": "https://builtwith.appwrite.io" +} +``` + +## ⚙️ Configuration + +| Setting | Value | +|-------------------|-----------------------------------| +| Runtime | Python (3.10) | +| Entrypoint | `src/main.py` | +| Build Commands | `pip install -r requirements.txt` | +| Permissions | `any` | +| Timeout (Seconds) | 15 | + +## 🔒 Environment Variables + +No environment variables required.