Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions node-14.5/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
49 changes: 49 additions & 0 deletions node-14.5/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 📧 Unnamed function

<!-- Give your function a name -->

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.

<!-- Update with your description, for example 'Create Stripe payment and return payment URL' -->

_Example input:_

No input

<!-- If input is expected, add example -->

_Example output:_

<!-- Update with your expected 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
<!-- Add your custom environments variables -->

## 🚀 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.
15 changes: 15 additions & 0 deletions node-14.5/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
42 changes: 42 additions & 0 deletions node-14.5/src/index.js
Original file line number Diff line number Diff line change
@@ -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,
});
}
1 change: 1 addition & 0 deletions node-15.5/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
49 changes: 49 additions & 0 deletions node-15.5/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 📧 Unnamed function

<!-- Give your function a name -->

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.

<!-- Update with your description, for example 'Create Stripe payment and return payment URL' -->

_Example input:_

No input

<!-- If input is expected, add example -->

_Example output:_

<!-- Update with your expected 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
<!-- Add your custom environments variables -->

## 🚀 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.
15 changes: 15 additions & 0 deletions node-15.5/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
42 changes: 42 additions & 0 deletions node-15.5/src/index.js
Original file line number Diff line number Diff line change
@@ -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,
});
}
1 change: 1 addition & 0 deletions node-17.0/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
49 changes: 49 additions & 0 deletions node-17.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 📧 Unnamed function

<!-- Give your function a name -->

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.

<!-- Update with your description, for example 'Create Stripe payment and return payment URL' -->

_Example input:_

No input

<!-- If input is expected, add example -->

_Example output:_

<!-- Update with your expected 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
<!-- Add your custom environments variables -->

## 🚀 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.
15 changes: 15 additions & 0 deletions node-17.0/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
42 changes: 42 additions & 0 deletions node-17.0/src/index.js
Original file line number Diff line number Diff line change
@@ -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,
});
}