diff --git a/node-14.5/.gitignore b/node-14.5/.gitignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/node-14.5/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/node-14.5/README.md b/node-14.5/README.md new file mode 100644 index 0000000..48e21ed --- /dev/null +++ b/node-14.5/README.md @@ -0,0 +1,49 @@ +# 📧 Unnamed function + + + +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. + +## 🤖 Documentation + +Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. + + + +_Example input:_ + +No input + + + +_Example output:_ + + + +```json +{ + "areDevelopersAwesome": true +} +``` + +## 📝 Environment Variables + +List of environment variables used by this cloud functions: + +- **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project +- **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key + + +## 🚀 Deployment + +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. + +### Using CLI + +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 AppwriteCLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. + +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. + +### Manual using tar.gz + +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. Finally, it's considered good practice to remove the build file from your function source folder. diff --git a/node-14.5/package.json b/node-14.5/package.json new file mode 100644 index 0000000..bb27645 --- /dev/null +++ b/node-14.5/package.json @@ -0,0 +1,15 @@ +{ + "name": "appwrite-function", + "version": "1.0.0", + "description": "", + "main": "src/index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "node-appwrite": "^4.0.2" + } +} diff --git a/node-14.5/src/index.js b/node-14.5/src/index.js new file mode 100644 index 0000000..dbbf8c3 --- /dev/null +++ b/node-14.5/src/index.js @@ -0,0 +1,42 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client(); + +// You can remove services you don't use +let account = new sdk.Account(client); +let avatars = new sdk.Avatars(client); +let database = new sdk.Database(client); +let functions = new sdk.Functions(client); +let helath = new sdk.Health(client); +let locale = new sdk.Locale(client); +let storage = new sdk.Storage(client); +let teams = new sdk.Teams(client); +let users = new sdk.Users(client); + +client + .setEndpoint(process.env.APPWRITE_FUNCTION_ENDPOINT) + .setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID) + .setKey(process.env.APPWRITE_FUNCTION_API_KEY); + +if(!process.env.APPWRITE_FUNCTION_ENDPOINT || !process.env.APPWRITE_FUNCTION_API_KEY) { + console.warn("Some environment variables are not set. Function cannot use AppwriteSDK properly."); +} + +/* + 'req' variable has: + 'headers' - object with request headers + 'payload' - object with request body data + 'env' - object with environment variables + + 'res' variable has: + 'send(text, status)' - function to return text response. Status code defaults to 200 + 'json(obj, status)' - function to return JSON response. Status code defaults to 200 + + If an error is thrown, a response with code 500 will be returned. +*/ + +module.exports = function(req, res) { + res.json({ + areDevelopersAwesome: true, + }); +} \ No newline at end of file diff --git a/node-15.5/.gitignore b/node-15.5/.gitignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/node-15.5/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/node-15.5/README.md b/node-15.5/README.md new file mode 100644 index 0000000..48e21ed --- /dev/null +++ b/node-15.5/README.md @@ -0,0 +1,49 @@ +# 📧 Unnamed function + + + +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. + +## 🤖 Documentation + +Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. + + + +_Example input:_ + +No input + + + +_Example output:_ + + + +```json +{ + "areDevelopersAwesome": true +} +``` + +## 📝 Environment Variables + +List of environment variables used by this cloud functions: + +- **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project +- **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key + + +## 🚀 Deployment + +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. + +### Using CLI + +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 AppwriteCLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. + +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. + +### Manual using tar.gz + +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. Finally, it's considered good practice to remove the build file from your function source folder. diff --git a/node-15.5/package.json b/node-15.5/package.json new file mode 100644 index 0000000..bb27645 --- /dev/null +++ b/node-15.5/package.json @@ -0,0 +1,15 @@ +{ + "name": "appwrite-function", + "version": "1.0.0", + "description": "", + "main": "src/index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "node-appwrite": "^4.0.2" + } +} diff --git a/node-15.5/src/index.js b/node-15.5/src/index.js new file mode 100644 index 0000000..dbbf8c3 --- /dev/null +++ b/node-15.5/src/index.js @@ -0,0 +1,42 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client(); + +// You can remove services you don't use +let account = new sdk.Account(client); +let avatars = new sdk.Avatars(client); +let database = new sdk.Database(client); +let functions = new sdk.Functions(client); +let helath = new sdk.Health(client); +let locale = new sdk.Locale(client); +let storage = new sdk.Storage(client); +let teams = new sdk.Teams(client); +let users = new sdk.Users(client); + +client + .setEndpoint(process.env.APPWRITE_FUNCTION_ENDPOINT) + .setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID) + .setKey(process.env.APPWRITE_FUNCTION_API_KEY); + +if(!process.env.APPWRITE_FUNCTION_ENDPOINT || !process.env.APPWRITE_FUNCTION_API_KEY) { + console.warn("Some environment variables are not set. Function cannot use AppwriteSDK properly."); +} + +/* + 'req' variable has: + 'headers' - object with request headers + 'payload' - object with request body data + 'env' - object with environment variables + + 'res' variable has: + 'send(text, status)' - function to return text response. Status code defaults to 200 + 'json(obj, status)' - function to return JSON response. Status code defaults to 200 + + If an error is thrown, a response with code 500 will be returned. +*/ + +module.exports = function(req, res) { + res.json({ + areDevelopersAwesome: true, + }); +} \ No newline at end of file diff --git a/node-17.0/.gitignore b/node-17.0/.gitignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/node-17.0/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/node-17.0/README.md b/node-17.0/README.md new file mode 100644 index 0000000..48e21ed --- /dev/null +++ b/node-17.0/README.md @@ -0,0 +1,49 @@ +# 📧 Unnamed function + + + +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. + +## 🤖 Documentation + +Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are. + + + +_Example input:_ + +No input + + + +_Example output:_ + + + +```json +{ + "areDevelopersAwesome": true +} +``` + +## 📝 Environment Variables + +List of environment variables used by this cloud functions: + +- **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project +- **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key + + +## 🚀 Deployment + +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. + +### Using CLI + +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 AppwriteCLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`. + +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. + +### Manual using tar.gz + +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. Finally, it's considered good practice to remove the build file from your function source folder. diff --git a/node-17.0/package.json b/node-17.0/package.json new file mode 100644 index 0000000..bb27645 --- /dev/null +++ b/node-17.0/package.json @@ -0,0 +1,15 @@ +{ + "name": "appwrite-function", + "version": "1.0.0", + "description": "", + "main": "src/index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "node-appwrite": "^4.0.2" + } +} diff --git a/node-17.0/src/index.js b/node-17.0/src/index.js new file mode 100644 index 0000000..dbbf8c3 --- /dev/null +++ b/node-17.0/src/index.js @@ -0,0 +1,42 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client(); + +// You can remove services you don't use +let account = new sdk.Account(client); +let avatars = new sdk.Avatars(client); +let database = new sdk.Database(client); +let functions = new sdk.Functions(client); +let helath = new sdk.Health(client); +let locale = new sdk.Locale(client); +let storage = new sdk.Storage(client); +let teams = new sdk.Teams(client); +let users = new sdk.Users(client); + +client + .setEndpoint(process.env.APPWRITE_FUNCTION_ENDPOINT) + .setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID) + .setKey(process.env.APPWRITE_FUNCTION_API_KEY); + +if(!process.env.APPWRITE_FUNCTION_ENDPOINT || !process.env.APPWRITE_FUNCTION_API_KEY) { + console.warn("Some environment variables are not set. Function cannot use AppwriteSDK properly."); +} + +/* + 'req' variable has: + 'headers' - object with request headers + 'payload' - object with request body data + 'env' - object with environment variables + + 'res' variable has: + 'send(text, status)' - function to return text response. Status code defaults to 200 + 'json(obj, status)' - function to return JSON response. Status code defaults to 200 + + If an error is thrown, a response with code 500 will be returned. +*/ + +module.exports = function(req, res) { + res.json({ + areDevelopersAwesome: true, + }); +} \ No newline at end of file