From aac3cc4d9c507986e1a296cd5b55c69036bff0d5 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 21 Jul 2023 14:31:54 +0100 Subject: [PATCH 1/2] feat: Kotlin starter --- kotlin/starter-template/.gitignore | 333 ++++++++++++++++++++++++++++ kotlin/starter-template/README.md | 48 ++++ kotlin/starter-template/deps.gradle | 3 + kotlin/starter-template/src/Main.kt | 37 ++++ 4 files changed, 421 insertions(+) create mode 100644 kotlin/starter-template/.gitignore create mode 100644 kotlin/starter-template/README.md create mode 100644 kotlin/starter-template/deps.gradle create mode 100644 kotlin/starter-template/src/Main.kt diff --git a/kotlin/starter-template/.gitignore b/kotlin/starter-template/.gitignore new file mode 100644 index 00000000..b9b5373f --- /dev/null +++ b/kotlin/starter-template/.gitignore @@ -0,0 +1,333 @@ +### Android ### +# Built application files +*.apk +*.ap_ +*.aab + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +.idea/caches + +# Keystore files +# Uncomment the following lines if you do not want to check your keystore files in. +#*.jks +#*.keystore + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild + +# Google Services (e.g. APIs or Firebase) +google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md + +### Android Patch ### +gen-external-apklibs + +### AndroidStudio ### +# Covers files to be ignored for android development using Android Studio. + +# Built application files + +# Files for the ART/Dalvik VM + +# Java class files + +# Generated files + +# Gradle files +.gradle + +# Signing files +.signing/ + +# Local configuration file (sdk path, etc) + +# Proguard folder generated by Eclipse + +# Log Files + +# Android Studio +/*/build/ +/*/local.properties +/*/out +/*/*/build +/*/*/production +*.ipr +*~ +*.swp + +# Android Patch + +# External native build folder generated in Android Studio 2.2 and later + +# NDK +obj/ + +# IntelliJ IDEA +*.iws +/out/ + +# User-specific configurations +.idea/caches/ +.idea/libraries/ +.idea/shelf/ +.idea/.name +.idea/compiler.xml +.idea/copyright/profiles_settings.xml +.idea/encodings.xml +.idea/misc.xml +.idea/modules.xml +.idea/scopes/scope_settings.xml +.idea/vcs.xml +.idea/jsLibraryMappings.xml +.idea/datasources.xml +.idea/dataSources.ids +.idea/sqlDataSources.xml +.idea/dynamic.xml +.idea/uiDesigner.xml + +# OS-specific files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# Legacy Eclipse project files +.classpath +.project +.cproject +.settings/ + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.war +*.ear + +# virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml) +hs_err_pid* + +## Plugin-specific files: + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Mongo Explorer plugin +.idea/mongoSettings.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +### AndroidStudio Patch ### + +!/gradle/wrapper/gradle-wrapper.jar + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format + +# IntelliJ + +# mpeltonen/sbt-idea plugin + +# JIRA plugin + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Intellij Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +.idea/sonarlint + +### Java ### +# Compiled class file + +# Log file + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) + +# Package Files # +*.jar +*.nar +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml + +### Linux ### + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.TemporaryItems +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Windows ### +# Windows thumbnail cache files +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.gitignore.io/api/java,linux,macos,windows,android,intellij,androidstudio \ No newline at end of file diff --git a/kotlin/starter-template/README.md b/kotlin/starter-template/README.md new file mode 100644 index 00000000..24e2aea6 --- /dev/null +++ b/kotlin/starter-template/README.md @@ -0,0 +1,48 @@ +# ⚡ Kotlin Starter Function + +A simple starter function. Edit `src/Main.kt` 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 | Kotlin (1.7) | +| Entrypoint | `src/Main.kt` | +| Build Commands | `gradle build` | +| Permissions | `any` | +| Timeout (Seconds) | 15 | + +## 🔒 Environment Variables + +No environment variables required. diff --git a/kotlin/starter-template/deps.gradle b/kotlin/starter-template/deps.gradle new file mode 100644 index 00000000..6bd8824c --- /dev/null +++ b/kotlin/starter-template/deps.gradle @@ -0,0 +1,3 @@ +dependencies { + implementation 'io.appwrite:sdk-for-kotlin:2.0.0' +} \ No newline at end of file diff --git a/kotlin/starter-template/src/Main.kt b/kotlin/starter-template/src/Main.kt new file mode 100644 index 00000000..bbe55143 --- /dev/null +++ b/kotlin/starter-template/src/Main.kt @@ -0,0 +1,37 @@ +import io.appwrite.Client +import java.util.HashMap + +class Main { + // This is your Appwrite function + // It's executed each time we get a request + fun main(context: RuntimeContext): RuntimeOutput { + // Why not try the Appwrite SDK? + // val client = Client().apply { + // setEndpoint("https://cloud.appwrite.io/v1") + // setProject(System.getenv("APPWRITE_PROJECT_ID")) + // setKey(System.getenv("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 `context.req` object contains the request data + if (context.req.method == "GET") { + // Send a response with the res object helpers + // `context.res.send()` dispatches a string back to the client + return context.res.send("Hello, World! 🌎") + } + + // `context.res.json()` is a handy helper for sending JSON + val jsonMap = HashMap().apply { + put("motto", "Build Fast. Scale Big. All in One Place.") + put("learn", "https://appwrite.io/docs") + put("connect", "https://appwrite.io/discord") + put("getInspired", "https://builtwith.appwrite.io") + } + return context.res.json(jsonMap) + } +} From 9f617a79e62d05b13fa1ce4161496ce4219ea473 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 21 Jul 2023 19:17:37 +0100 Subject: [PATCH 2/2] docs: remove build command for kotlin --- kotlin/starter-template/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/kotlin/starter-template/README.md b/kotlin/starter-template/README.md index 24e2aea6..076d4336 100644 --- a/kotlin/starter-template/README.md +++ b/kotlin/starter-template/README.md @@ -39,7 +39,6 @@ Sample `200` Response: |-------------------|----------------| | Runtime | Kotlin (1.7) | | Entrypoint | `src/Main.kt` | -| Build Commands | `gradle build` | | Permissions | `any` | | Timeout (Seconds) | 15 |