diff --git a/app/views/docs/functions-develop.phtml b/app/views/docs/functions-develop.phtml index 4f5adbb6..efef145b 100644 --- a/app/views/docs/functions-develop.phtml +++ b/app/views/docs/functions-develop.phtml @@ -124,13 +124,13 @@ def main(context): # If something goes wrong, log an error context.error("Hello, Errors!") - # The `ctx.req` object contains the request data + # The `context.req` object contains the request data if context.req.method == "GET": # Send a response with the res object helpers - # `ctx.res.send()` dispatches a string back to the client + # `context.res.send()` dispatches a string back to the client return context.res.send("Hello, World!") - # `ctx.res.json()` is a handy helper for sending JSON + # `context.res.json()` is a handy helper for sending JSON return context.res.json( { "motto": "Build Fast. Scale Big. All in One Place.", @@ -163,22 +163,20 @@ def main(context) # If something goes wrong, log an error context.error("Hello, Errors!") - # The `ctx.req` object contains the request data + # The `context.req` object contains the request data if (context.req.method == "GET") # Send a response with the res object helpers - # `ctx.res.send()` dispatches a string back to the client + # `context.res.send()` dispatches a string back to the client return context.res.send("Hello, World!") end - # `ctx.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", - } - ) + # `context.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", + }) end @@ -286,7 +284,7 @@ func main(context: RuntimeContext) async throws -> RuntimeOutput { if context.req.method == "GET" { // Send a response with the res object helpers // `res.send()` dispatches a string back to the client - return try context.res.send("Hello, World!") + return context.res.send("Hello, World!") } // `context.res.json()` is a handy helper for sending JSON @@ -671,7 +669,7 @@ func main(context: RuntimeContext) async throws -> RuntimeOutput { context.log(context.req.queryString) // Raw query params string. For example "limit=12&offset=50" context.log(NSJSONSerialization.jsonObject(with: context.req.query, options: [])!) // Parsed query params. For example, req.query.limit - return try context.res.send("All the request parameters are logged to the Appwrite Console.") + return context.res.send("All the request parameters are logged to the Appwrite Console.") } @@ -764,10 +762,10 @@ public class Main { -

Headers

+

Headers

Appwrite Functions will always receive a set of headers that provide meta data about the function execution. - These are provided along side any custom headers sent to the function. + These are provided alongside any custom headers sent to the function.

@@ -841,10 +839,10 @@ public class Main {
export default async ({ req, res, log }) => {
 
     switch (req.query.type) {
-        case 'text': 
-            return res.send("This is a text response", 200);
+        case 'empty': 
+            return res.empty();
         case 'json':
-            return res.json({"type": "This is a JSON response"}, 200);
+            return res.json({"type": "This is a JSON response"});
         case 'redirect':
             return res.redirect("https://appwrite.io", 301);
         case 'html':
@@ -853,7 +851,7 @@ public class Main {
                     "content-type": "text/html"
                 });
         default:
-            return res.empty();
+            return res.send("This is a text response");
     }
 }
@@ -865,10 +863,10 @@ public class Main { return function ($context) { switch ($context->req->query['type']) { - case 'text': - return $context->res->send("This is a text response", 200); + case 'empty': + return $context->res->empty(); case 'json': - return $context->res->json(["type" => "This is a JSON response"], 200); + return $context->res->json(["type" => "This is a JSON response"]); case 'redirect': return $context->res->redirect("https://appwrite.io", 301); case 'html': @@ -876,7 +874,7 @@ return function ($context) { "content-type" => "text/html" ]); default: - return $context->res->empty(); + return $context->res->send("This is a text response"); } }; @@ -886,10 +884,10 @@ return function ($context) {
def main(context):
     switch context.req.query['type']:
-        case 'text':
-            return context.res.send("This is a text response", 200)
+        case 'empty':
+            return context.res.empty()
         case 'json':
-            return context.res.json({"type": "This is a JSON response"}, 200)
+            return context.res.json({"type": "This is a JSON response"})
         case 'redirect':
             return context.res.redirect("https://appwrite.io", 301)
         case 'html':
@@ -897,7 +895,7 @@ return function ($context) {
                 "content-type": "text/html"
             })
         default:
-            return context.res.empty()
+ return context.res.send("This is a text response")
  • @@ -905,10 +903,10 @@ return function ($context) {
    def main(context)
         case context.req.query['type'] 
    -        when 'text'
    -            return context.res.send("This is a text response", 200)
    +        when 'empty'
    +            return context.res.empty()
             when 'json'
    -            return context.res.json({"type": "This is a JSON response"}, 200)
    +            return context.res.json({"type": "This is a JSON response"})
             when 'redirect'
                 return context.res.redirect("https://appwrite.io", 301)
             when 'html'
    @@ -916,7 +914,7 @@ return function ($context) {
                     "content-type": "text/html"
                 })
             else
    -            return context.res.empty()
    +            return context.res.send("This is a text response")
         end
     end
    @@ -927,10 +925,10 @@ end
    export default async ({ req, res, log }) => {
     
         switch (req.query.type) {
    -        case 'text':
    -            return res.send("This is a text response", 200);
    +        case 'empty':
    +            return res.empty();
             case 'json':
    -            return res.json({type": "This is a JSON response"}, 200);
    +            return res.json({type": "This is a JSON response"});
             case 'redirect':
                 return res.redirect("https://appwrite.io", 301);
             case 'html':
    @@ -939,7 +937,7 @@ end
    "content-type": "text/html" }); default: - return res.empty(); + return res.send("This is a text response"); } } @@ -951,24 +949,18 @@ end Future<dynamic> main(final context) async { switch (context.req.query['type']) { - case 'text': - return context.res - .send('This is a text response', 200); + case 'empty': + return context.res.empty(); case 'json': - return context.res - .json({'type': 'This is a JSON response'}); + return context.res.json({'type': 'This is a JSON response'}); case 'redirect': - return context.res - .redirect('https://appwrite.io', 301); + return context.res.redirect('https://appwrite.io', 301); case 'html': - return context.res - .send('<h1>This is an HTML response</h1>', 200, { - 'content-type': 'text/html' - }); + return context.res.send('<h1>This is an HTML response</h1>', + 200, {'content-type': 'text/html'}); default: - return context.res - .empty(); - } + return context.res.send('This is a text response'); + } }
  • @@ -979,18 +971,18 @@ Future<dynamic> main(final context) async { func main(context: RuntimeContext) async throws -> RuntimeOutput { switch context.req.query["type"] { - case "text": - return try await context.send("This is a text response", 200) + case "empty": + return context.res.empty() case "json": - return try await context.send(["type": "This is a JSON response"], 200) + return context.res.send(["type": "This is a JSON response"]) case "redirect": - return try await context.redirect("https://appwrite.io", 301) + return context.res.redirect("https://appwrite.io", 301) case "html": - return try await context.send("<h1>This is an HTML response</h1>", 200, [ + return context.res.send("<h1>This is an HTML response</h1>", 200, [ "content-type": "text/html" ]) default: - return try await context.empty() + return context.res.send("This is a text response") } } @@ -1005,18 +997,18 @@ public class Handler { { switch (Context.Request.Query["type"]) { - case "text": - return await Context.Send("This is a text response", 200); + case "empty": + return Context.Res.Empty(); case "json": - return await Context.Send(new Dictionary<string, object>() { { "type", "This is a JSON response" } }, 200); + return Context.Res.Send(new Dictionary<string, object>() { { "type", "This is a JSON response" } }); case "redirect": - return await Context.Redirect("https://appwrite.io", 301); + return Context.Res.Redirect("https://appwrite.io", 301); case "html": - return await Context.Send("<h1>This is an HTML response</h1>", 200, new Dictionary<string, string>() { + return Context.Res.Send("<h1>This is an HTML response</h1>", 200, new Dictionary<string, string>() { { "content-type", "text/html" } }); - default: - return await Context.Empty(); + default: + return Context.Res.Send("This is a text response"); } } } @@ -1033,11 +1025,11 @@ import io.openruntimes.kotlin.RuntimeOutput class Main { fun main(context: RuntimeContext): RuntimeOutput { when (context.req.query["type"]) { - "text" -> return context.send("This is a text response", 200) - "json" -> return context.send(mapOf("type" to "This is a JSON response"), 200) - "redirect" -> return context.redirect("https://appwrite.io", 301) - "html" -> return context.send("<h1>This is an HTML response</h1>", 200, mapOf("content-type" to "text/html")) - else -> return context.empty() + "empty" -> return context.res.empty() + "json" -> return context.res.send(mapOf("type" to "This is a JSON response")) + "redirect" -> return context.res.redirect("https://appwrite.io", 301) + "html" -> return context.res.send("<h1>This is an HTML response</h1>", 200, mapOf("content-type" to "text/html")) + else -> return context.res.send("This is a text response") } } } @@ -1057,17 +1049,17 @@ public class Main { public RuntimeOutput main(RuntimeContext context) throws Exception { switch (context.getReq().getQuery()["type"]) { case "text": - return context.send("This is a text response", 200); + return context.getRes().empty(); case "json": HashMap<String, Object> data = new HashMap<>(); data.put("type", "This is a JSON response"); - return context.send(data, 200); + return context.getRes().send(data); case "redirect": - return context.redirect("https://appwrite.io", 301); + return context.getRes().redirect("https://appwrite.io", 301); case "html": - return context.send("<h1>This is an HTML response</h1>", 200, Map.of("content-type", "text/html")); + return context.getRes().send("<h1>This is an HTML response</h1>", 200, Map.of("content-type", "text/html")); default: - return context.empty(); + return context.getRes().send("This is a text response"); } } } @@ -1087,20 +1079,20 @@ namespace runtime { static RuntimeOutput main(RuntimeContext &context) { std::string type = context.req.query["type"]; - if (type == "text") { - return context.send("This is a text response", 200); + if (type == "empty") { + return context.res.empty(); } else if (type == "json") { Json::Value data; data["type"] = "This is a JSON response"; - return context.send(data, 200); + return context.res.send(data); } else if (type == "redirect") { - return context.redirect("https://appwrite.io", 301); + return context.res.redirect("https://appwrite.io", 301); } else if (type == "html") { Json::Value headers; headers["content-type"] = "text/html"; - return context.send("<h1>This is an HTML response</h1>", 200, headers); + return context.res.send("<h1>This is an HTML response</h1>", 200, headers); } else { - return context.empty(); + return context.res.send("This is a text response"); } } }; @@ -1162,9 +1154,9 @@ namespace runtime {
  • Node.js

    -
    export default async ({ res, log, error }) => {
    +                
    export default async ({ req, res, log, error }) => {
         log("This is a log, use for logging information to console");
    -    log(`This function was called with ${context.req.method} method`);
    +    log(`This function was called with ${req.method} method`);
         error("This is an error, use for logging errors to console");
     
         return res.send("Check the Appwrite Console to see logs and errors!");
    @@ -1193,7 +1185,7 @@ return function ($context) {
         context.log(f"This function was called with {context.req.method} method")
         context.error("This is an error, use for logging errors to console")
     
    -    return context.send("Check the Appwrite Console to see logs and errors!")
    + return context.res.send("Check the Appwrite Console to see logs and errors!")
  • @@ -1204,7 +1196,7 @@ return function ($context) { context.log("This function was called with #{context.req.method} method") context.error("This is an error, use for logging errors to console") - return context.send("Check the Appwrite Console to see logs and errors!") + return context.res.send("Check the Appwrite Console to see logs and errors!") end
  • @@ -1230,7 +1222,7 @@ Future<dynamic> main(final context) async { context.log("This function was called with ${context.req.method} method"); context.error("This is an error, use for logging errors to console"); - return context.send("Check the Appwrite Console to see logs and errors!"); + return context.res.send("Check the Appwrite Console to see logs and errors!"); } @@ -1244,7 +1236,7 @@ func main(context: RuntimeContext) async throws -> RuntimeOutput { context.log("This function was called with \(context.req.method) method") context.error("This is an error, use for logging errors to console") - return try context.send("Check the Appwrite Console to see logs and errors!") + return context.res.send("Check the Appwrite Console to see logs and errors!") } @@ -1260,7 +1252,7 @@ public class Handler { Context.Log($"This function was called with {Context.Req.Method} method"); Context.Error("This is an error, use for logging errors to console"); - return await Context.Send("Check the Appwrite Console to see logs and errors!"); + return Context.Res.Send("Check the Appwrite Console to see logs and errors!"); } } @@ -1279,7 +1271,7 @@ class Main { context.log("This function was called with ${context.req.method} method") context.error("This is an error, use for logging errors to console") - return context.send("Check the Appwrite Console to see logs and errors!") + return context.res.send("Check the Appwrite Console to see logs and errors!") } } @@ -1298,7 +1290,7 @@ public class Main { context.log("This function was called with " + context.req.method + " method"); context.error("This is an error, use for logging errors to console"); - return context.send("Check the Appwrite Console to see logs and errors!"); + return context.getRes().send("Check the Appwrite Console to see logs and errors!"); } } @@ -1319,7 +1311,7 @@ namespace runtime { context.log("This function was called with " + context.req.method + " method"); context.error("This is an error, use for logging errors to console"); - return context.send("Check the Appwrite Console to see logs and errors!"); + return context.res.send("Check the Appwrite Console to see logs and errors!"); } }; } @@ -1433,7 +1425,7 @@ namespace runtime {

    Node.js

    export default async ({ req, res, log }) => {
    -    return res.send(process.env.MY_VAR, 200);
    +    return res.send(process.env.MY_VAR);
     }
    @@ -1443,7 +1435,7 @@ namespace runtime {
    <?php
     
     return function ($context) {
    -    return $context->res->send(getenv('MY_VAR'), 200);
    +    return $context->res->send(getenv('MY_VAR'));
     };
    @@ -1451,14 +1443,14 @@ return function ($context) {

    Python

    def main(context):
    -    return context.res.send(os.environ['MY_VAR'], 200)
    + return context.res.send(os.environ['MY_VAR'])
  • Ruby

    def main(context)
    -    return context.res.send(ENV['MY_VAR'], 200)
    +    return context.res.send(ENV['MY_VAR'])
     end
  • @@ -1466,7 +1458,7 @@ end

    Deno

    export default async ({ req, res, log }) => {
    -    return res.send(Deno.env.get('MY_VAR'), 200);
    +    return res.send(Deno.env.get('MY_VAR'));
     }
    @@ -1476,7 +1468,7 @@ end
    import 'dart:async';
     
     Future<dynamic> main(final context) async {
    -    return context.res.send(Platform.environment['MY_VAR'], 200);
    +    return context.res.send(Platform.environment['MY_VAR']);
     }
    @@ -1486,7 +1478,7 @@ Future<dynamic> main(final context) async {
    import Foundation
     
     func main(context: RuntimeContext) async throws -> RuntimeOutput {
    -    return try await context.send(ProcessInfo.processInfo.environment["MY_VAR"], 200)
    +    return context.res.send(ProcessInfo.processInfo.environment["MY_VAR"])
     }
    @@ -1498,7 +1490,7 @@ func main(context: RuntimeContext) async throws -> RuntimeOutput { public class Handler { public async Task<RuntimeOutput> Main(RuntimeContext Context) { - return await Context.Send(Environment.GetEnvironmentVariable("MY_VAR"), 200); + return Context.Res.Send(Environment.GetEnvironmentVariable("MY_VAR")); } } @@ -1513,7 +1505,7 @@ import io.openruntimes.kotlin.RuntimeOutput class Main { fun main(context: RuntimeContext): RuntimeOutput { - return context.send(System.getenv("MY_VAR"), 200) + return context.res.send(System.getenv("MY_VAR")) } } @@ -1528,7 +1520,7 @@ import io.openruntimes.java.RuntimeOutput; public class Main { public RuntimeOutput main(RuntimeContext context) throws Exception { - return context.send(System.getenv("MY_VAR"), 200); + return context.getRes().send(System.getenv("MY_VAR")); } } @@ -1546,7 +1538,7 @@ namespace runtime { public: static RuntimeOutput main(RuntimeContext &context) { - return context.send(std::getenv("MY_VAR"), 200); + return context.res.send(std::getenv("MY_VAR")); }; } @@ -1559,114 +1551,114 @@ namespace runtime { Your function's dependencies should be managed by the package manager of each language. By default, we include the following package managers in each runtime:

    -
    - +
    + + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    LanguagePackage ManagerCommands
    LanguagePackage ManagerCommands + Node icon + Node.jsnpmnpm install
    - Node icon - Node.jsnpmnpm install
    - PHP icon - PHPComposercomposer install
    - Python icon - Pythonpippip install -r requirements.txt
    - Ruby icon - RubyBundlerbundle install
    - Deno icon - Denodenodeno cache <ENTRYPOINT_FILE>
    - Dart icon - Dartpubpub get
    - Swift icon - SwiftSwift Package ManagerN/A
    - Swift icon - .NETNuGetN/A
    - Swift icon - KotlinGradleN/A
    - Swift icon - JavaGradleN/A
    - C++ icon - C++NoneN/A
    + + + PHP icon + + PHP + Composer + composer install + + + + Python icon + + Python + pip + pip install -r requirements.txt + + + + Ruby icon + + Ruby + Bundler + bundle install + + + + Deno icon + + Deno + deno + deno cache <ENTRYPOINT_FILE> + + + + Dart icon + + Dart + pub + pub get + + + + Swift icon + + Swift + Swift Package Manager + N/A + + + + Swift icon + + .NET + NuGet + N/A + + + + Swift icon + + Kotlin + Gradle + N/A + + + + Swift icon + + Java + Gradle + N/A + + + + C++ icon + + C++ + None + N/A + + -

    - To install your dependencies before your function is built, you should add the relevant install command to the top your function's Build setting > Commands. -

    +

    + To install your dependencies before your function is built, you should add the relevant install command to the top your function's Build setting > Commands. +

    Using Appwrite in a Function

    - Appwrite can be used in your functions by adding the relevant SDK to your function's dependencies. - Authenticating with Appwrite is done via an API key or a JWT token. + Appwrite can be used in your functions by adding the relevant SDK to your function's dependencies. + Authenticating with Appwrite is done via an API key or a JWT token. API keys must be generated and exported as an environment variable.

    @@ -1868,7 +1860,7 @@ func main(context: RuntimeContext) async throws -> RuntimeOutput { try await databases.createDocument(databaseId: "[DATABASE_ID]", collectionId: "[COLLECTION_ID]", data: [:]) } catch { context.error("Failed to create document: \(error.localizedDescription)") - return try await context.res.send("Failed to create document") + return context.res.send("Failed to create document") } return context.res.send("Document created") @@ -2353,7 +2345,7 @@ export function add(a, b) { import { add } from './utils.js'; -export default function ({res}) { +export default function ({ res }) { return res.send(add(1, 2)); } @@ -2389,10 +2381,10 @@ def add(a, b):

    // src/main.py
     
    -import utils
    +from .utils import add
     
     def main(context):
    -    return context.res.send(utils.add(1, 2))
    + return context.res.send(add(1, 2))
  • diff --git a/app/views/docs/functions-examples.phtml b/app/views/docs/functions-examples.phtml index 485c4fe3..0fdabae8 100644 --- a/app/views/docs/functions-examples.phtml +++ b/app/views/docs/functions-examples.phtml @@ -139,6 +139,43 @@ export default async function ({ req, res }) {
  • +
  • +

    PHP

    +
    +

    +

    +
    <?php
    +
    +require(__DIR__ . '/../vendor/autoload.php');
    +
    +use Appwrite\Client;
    +use Appwrite\Exception;
    +use Appwrite\Services\Database;
    +use GuzzleHttp\Client as GuzzleClient;
    +
    +return function ($context) {
    +    $client = new GuzzleClient();
    +
    +    if ($context->req->path === '/eur') {
    +        $amountInEuros = floatval($context->req->query['amount']);
    +        $response = $client->get('https://api.exchangerate.host/latest?base=EUR&symbols=USD');
    +        $data = $response->json();
    +        $amountInDollars = $amountInEuros * $data['rates']['USD'];
    +        return $context->res->send(strval($amountInDollars));
    +    }
    +
    +    if ($context->req->path === '/inr') {
    +        $amountInRupees = floatval($context->req->query['amount']);
    +        $response = $client->get('https://api.exchangerate.host/latest?base=INR&symbols=USD');
    +        $data = $response->json();
    +        $amountInDollars = $amountInRupees * $data['rates']['USD'];
    +        return $context->res->send(strval($amountInDollars));
    +    }
    +
    +    return $context->res->send('Invalid path');
    +};
    +
    +
  • Python

    @@ -361,10 +398,12 @@ def main(context): if vote['vote'] != 'yes' and vote['vote'] != 'no': return context.res.json({'ok': False, 'message': 'You must vote yes or no.'}, 400) - client = Client() - client.set_endpoint('https://cloud.appwrite.io/v1') - client.set_project(os.environ['APPWRITE_FUNCTION_PROJECT_ID']) - client.set_key(os.environ['APPWRITE_API_KEY']) + client = ( + Client() + .set_endpoint("https://cloud.appwrite.io/v1") + .set_project(os.environ["APPWRITE_FUNCTION_PROJECT_ID"]) + .set_key(os.environ["APPWRITE_API_KEY"]) + ) database = Databases(client) @@ -555,55 +594,6 @@ Future main(final context) async {
  • -
  • -

    Python

    -
    -

    -

    -
    from appwrite.client import Client
    -from appwrite.services.databases import Databases
    -from appwrite.query import Query
    -
    -import os
    -
    -def main(context):
    -    vote = {
    -        'userId': context.req.query['userId'],
    -        'topicId': context.req.query['topicId'],
    -        'vote': context.req.query['vote']
    -    }
    -
    -    if vote['vote'] != 'yes' and vote['vote'] != 'no':
    -        return context.res.json({'ok': False, 'message': 'You must vote yes or no.'}, 400)
    -
    -    client = Client()
    -    client.set_endpoint('https://cloud.appwrite.io/v1')
    -    client.set_project(os.environ['APPWRITE_FUNCTION_PROJECT_ID'])
    -    client.set_key(os.environ['APPWRITE_API_KEY'])
    -
    -    database = Databases(client)
    -
    -    existing_votes = database.list_documents('[VOTES_COLLECTION_ID]', [
    -        Query.equal('userId', vote['userId']),
    -        Query.equal('topicId', vote['topicId'])
    -    ])
    -    
    -    if existing_votes['total'] > 0:
    -        return context.res.json({
    -          'ok': False, 
    -          'message': 'You have already voted on this topic.'
    -        }, 400)
    -
    -    vote_document = database.create_document('[VOTES_COLLECTION_ID]', vote)
    -
    -    return context.res.json({
    -      'ok': True, 
    -      'message': 'Vote cast.', 
    -      'vote': vote_document
    -    })
    -
    -
    -
  • @@ -696,7 +686,7 @@ export default async function ({ req, res }) { const databases = new Databases(client); const document = await databases.createDocument('[DATABASE_ID]', '[MESSAGES_COLLECTION_ID]', ID.unique(), message); - return res.send("Message sent", 200); + return res.send("Message sent"); } return res.send('Not found', 404); @@ -746,16 +736,16 @@ def main(context): } client = ( - Client() - .set_endpoint('https://cloud.appwrite.io/v1') - .set_project(os.environ['APPWRITE_FUNCTION_PROJECT_ID']) - .set_key(os.environ['APPWRITE_API_KEY']) + Client() + .set_endpoint("https://cloud.appwrite.io/v1") + .set_project(os.environ["APPWRITE_FUNCTION_PROJECT_ID"]) + .set_key(os.environ["APPWRITE_API_KEY"]) ) databases = Databases(client) document = databases.create_document('[DATABASE_ID]', '[MESSAGES_COLLECTION_ID]', ID.unique(), message) - return context.res.send("Message sent", 200) + return context.res.send("Message sent") return context.res.send('Not found', 404) @@ -815,7 +805,7 @@ return function ($context) { $databases = new Databases($client); $document = $databases->createDocument('[DATABASE_ID]', '[MESSAGES_COLLECTION_ID]', ID::unique(), $message); - return $context->res->send("Message sent", 200); + return $context->res->send("Message sent"); } return $context->res->send('Not found', 404); @@ -870,7 +860,7 @@ def main(context) databases = Appwrite::Database.new(client) document = databases.create_document('[DATABASE_ID]', '[MESSAGES_COLLECTION_ID]', ID.unique(), message) - return context.res.send("Message sent", 200) + return context.res.send("Message sent") end return context.res.send('Not found', 404) @@ -925,7 +915,7 @@ Future main(final context) async { final databases = Database(client); final document = await databases.createDocument('[DATABASE_ID]', '[MESSAGES_COLLECTION_ID]', ID.unique(), message); - return context.res.send("Message sent", 200); + return context.res.send("Message sent"); } return context.res.send('Not found', 404);