Back

Appwrite 1.4

  • 1
  • Web
L
16 Feb, 2024, 16:01

]I have a doubt. I was using Appwrite in version 1.3 and updated to version 1.4. I would like to know if there have been changes to the structure or if I can use the functions from version 1.3 in version 1.4?

function 1.3

TypeScript
module.exports = async function (req, res) {

  const client = new Client()
  .setEndpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT'])
  .setProject(req.variables['APPWRITE_FUNCTION_PROJECT_ID'])
  .setKey(req.variables['APPWRITE_FUNCTION_API_KEY'])
  .setSelfSigned(true);

  const databases = new  Databases(client); 

  const reqPayload = req.payload;
  const { id_order} = JSON.parse(reqPayload);
}```

Or do I really need to put it in this model below

function 1.4

module.exports = async function (context) { const client = new Client() .setEndpoint(process.env["APPWRITE_FUNCTION_ENDPOINT"]) .setProject(process.env["APPWRITE_FUNCTION_PROJECT_ID"]) .setKey(process.env["APPWRITE_FUNCTION_API_KEY"]) .setSelfSigned(true);

const databases = new Databases(client); const body = context.req.bodyRaw; ```

TL;DR
In Appwrite 1.4, you can still run functions from 1.3 without changing the syntax. However, it is recommended to upgrade your function syntax due to the many great changes in 1.4. You can find more information in the documentation here: [link to documentation]. If you want to continue using 1.3 functions in 1.4, you can still use `req.variables['APPWRITE_FUNCTION_ENDPOINT']` for environment variables and `req.payload` for the request body. The recommended syntax for 1.4 is to use `process.env["APPWRITE_FUNCTION_ENDPOINT"]` for environment variables
Guille
16 Feb, 2024, 16:39

Appwrite 1.4 will keep executing function from 1.3, however there are many great changes in 1.4 that worth to upgrade your function syntax, you can check detailed information from here:

https://appwrite.io/docs/products/functions/development#upgrade

L
16 Feb, 2024, 16:55

But could I run the 1.3 functions in 1.4.2 without changing the syntax? For example, could I continue to get environment variables in Appwrite 1.4 using req.variables? Or even getting the body that comes in the request using req.payload? Or would I actually need to change to process.env and req.body/bodyRaw

I didn't find anything about this in the documentation.

Guille
16 Feb, 2024, 16:57

Yes, you could still run the 1.3 function without any change after upgrade

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more