-
Notifications
You must be signed in to change notification settings - Fork 117
Conversation
Behind the simple workflow hides some useful recipes that can help you accomplish your goals faster. | ||
Take a look at the following. | ||
</p> | ||
[TODO: @matej @luke -> Let's have some simple recipes here for common actions] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example: Matej suggested these, would be a starting point:
Hmm here is an idea, let me know what you think:
Section 1: My first function
We inform we are going to build currency convertion function
Create new file, index.js
We put some very very simple code into index.js, statically returning 1.13 (because 1€ = 1.13$)
We use git to init, commit, add remote and push
We create function in Console
We exectue function and see response 1.13 (by visiting URL like ghrfu9ewji.functions.appwrite.app)
Section 2: Let's use Payload
We update code in index.js to use req.query.amount. In URL param we recieve how much money you want to convert. Let's say body is 5 (€), we would return 5.63 ($). Still only using static math ($ = € * 1.13)
Push, wait a little, refresh static domain
Play with different params and see resposne number change
Section 3: Installing dependencies
Run npm init --yes to prepare dependency file
Install HTTP client library, npm install axios
Use axios with exchange API to get the rate instead of having it static. FOr example this, it's 100% free without limits: https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/eur/usd.json
Push, wait a little, refresh static domain
Play around and see same results, just a bit more precise
Section 4: More routes
Edit index.js to support multipel paths like /eur, /czk, /ft, /rub...
Push, deploy..
Try different endpoints, see they all convert that currency into $
Aaaand we can make this very generic, and have code and command snippets switchable between all runtimes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done for js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done for php dart ruby python
</div> | ||
|
||
<h3>Manual Deployment</h3> | ||
<p>You can also upload your functions to be deployed using the Appwrite console. The example below shows a simple Node.JS function, but the same idea applies to any other language.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<p>You can also upload your functions to be deployed using the Appwrite console. The example below shows a simple Node.JS function, but the same idea applies to any other language.</p> | |
<p>You can upload your functions to be deployed using the Appwrite Console. The example below shows a simple Node.js function, but the same idea applies to any other language.</p> |
</li> | ||
</ul> | ||
|
||
<p>Next, navigate to your Appwrite console and upload the function.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<p>Next, navigate to your Appwrite console and upload the function.</p> | |
<p>Next, navigate to your Appwrite Console and upload the function.</p> |
<li class="margin-bottom-small">Click <b>Create</b> to deploy your function.</li> | ||
</ol> | ||
|
||
<h2><a href="#domains" id="domains">Domains</a></h2> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm a bit concerned here. Should this be in deploy, or execute section? 🤔
On one hand, it makes sense here as someone deploying their function to production needs this information.
On the other hand, we talk about how to execute using domain in execute page. So it might make sense there as well.
Your call, just wanted to bring in the chaos 😈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both
<ol class="margin-top margin-bottom-large text-size-normal"> | ||
<li class="margin-bottom-small">Navigate to the Appwrite Console's <b>Functions</b> page.</li> | ||
<li class="margin-bottom-small">Navigate to the <b>Domains</b> tab.</li> | ||
<li class="margin-bottom-small">In the table, you'll find a link formatted similar to <code>https://64d4d22db370ae41a32e.appwrite.global</code>. This is your preview.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets not call it "preview". THat insicates it cant be used for production, but it can.
<li>In Appwrite Console, navigate to <b>Functions</b>.</li> | ||
<li>Click to open a function you wish to inspect.</li> | ||
<li>Under the <b>Deployments</b> tab, you'll find the status of the current active deployment.</li> | ||
<li>You can redeploy by clicking the <b>Redeploy</b> button.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets mention that you can redeploy failed execution by clicking 3 dots and finding same Redeploy button
Here's everything you need to know to deploy your first Appwrite Function. | ||
</p> | ||
|
||
<h2><a href="#vcs" id="vcs">VCS (Version Control System)</a></h2> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not entirely onboard with calling it VCS in docs. I think calling it Git, and mentioning GitHub would feel more natural to developer. You can double check with Eldad.
Co-authored-by: Matej Bačo <[email protected]>
Co-authored-by: Matej Bačo <[email protected]>
…n the copy button
What does this PR do?
(Provide a description of what this PR does.)
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)
Related PRs and Issues
(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)
Have you read the Contributing Guidelines on issues?
(Write your answer here.)