Back

Flow to create a function

  • 0
  • Functions
Mickaël LT
21 Mar, 2023, 10:23

Hi, What is the best way to create a function ? I've create a function with the cli, upload it to my server with the cli, it crash, I examine log, i fix, reupload, it run, etc. But If I want to test it before deploy how can I do that ? Any tips or best practice ?

TL;DR
There is a function example in Deno provided at this link: https://github.com/Meldiron/tmstats/blob/master/backend/functions/nadeoAction/src/test.ts. The example involves creating a test file that imports the function's entry point and executes it using fake request and response objects. The response is logged to the console. If you want to test your function before deployment, you can follow this example.
joeyouss
21 Mar, 2023, 10:53

Hi, @Meldiron has an example in Deno listed here: https://github.com/Meldiron/tmstats/blob/master/backend/functions/nadeoAction/src/test.ts. The idea is to have a test file that imports entrypoint of the function, and executes. It fakes req and res objects, providing test data for variables, payload.. Response is faked by printing into console.

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