Skip to content

Commit

Permalink
Merge pull request #772 from KBVE/patch-brainstorm-ai-agents
Browse files Browse the repository at this point in the history
Pulling refs/heads/patch-brainstorm-ai-agents into Dev
  • Loading branch information
h0lybyte authored Aug 22, 2023
2 parents 8d67ec2 + b7cfb81 commit 01e3eea
Show file tree
Hide file tree
Showing 62 changed files with 2,250 additions and 667 deletions.
21 changes: 14 additions & 7 deletions .astro/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,6 @@ declare module 'astro:content' {
collection: "application";
data: InferEntrySchema<"application">
} & { render(): Render[".mdx"] };
"automation/n8n.mdx": {
id: "automation/n8n.mdx";
slug: "automation/n8n";
body: string;
collection: "application";
data: InferEntrySchema<"application">
} & { render(): Render[".mdx"] };
"cubejs/cubejs.mdx": {
id: "cubejs/cubejs.mdx";
slug: "cubejs";
Expand Down Expand Up @@ -378,6 +371,13 @@ declare module 'astro:content' {
collection: "application";
data: InferEntrySchema<"application">
} & { render(): Render[".mdx"] };
"n8n/n8n.mdx": {
id: "n8n/n8n.mdx";
slug: "n8n";
body: string;
collection: "application";
data: InferEntrySchema<"application">
} & { render(): Render[".mdx"] };
"nginx/nginx.mdx": {
id: "nginx/nginx.mdx";
slug: "nginx";
Expand Down Expand Up @@ -1454,6 +1454,13 @@ declare module 'astro:content' {
collection: "journal";
data: InferEntrySchema<"journal">
} & { render(): Render[".md"] };
"08-17.md": {
id: "08-17.md";
slug: "08-17";
body: string;
collection: "journal";
data: InferEntrySchema<"journal">
} & { render(): Render[".md"] };
"asset.mdx": {
id: "asset.mdx";
slug: "asset";
Expand Down
24 changes: 12 additions & 12 deletions src/content/.obsidian/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"state": {
"type": "markdown",
"state": {
"file": "journal/08-16.md",
"file": "journal/08-22.md",
"mode": "source",
"source": false
}
Expand Down Expand Up @@ -93,7 +93,7 @@
"state": {
"type": "backlink",
"state": {
"file": "journal/08-16.md",
"file": "journal/08-22.md",
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical",
Expand All @@ -110,7 +110,7 @@
"state": {
"type": "outgoing-link",
"state": {
"file": "journal/08-16.md",
"file": "journal/08-22.md",
"linksCollapsed": false,
"unlinkedCollapsed": true
}
Expand All @@ -133,7 +133,7 @@
"state": {
"type": "outline",
"state": {
"file": "journal/08-16.md"
"file": "journal/08-22.md"
}
}
}
Expand All @@ -157,6 +157,13 @@
},
"active": "1e65db65e2721f35",
"lastOpenFiles": [
"journal/08-21.md",
"journal/08-20.md",
"journal/08-22.md",
"journal/08-18.md",
"journal/08-17.md",
"journal/08-19.md",
"journal/08-16.md",
"project/rentearth/_graph/data-structure.mdx",
"project/rentearth/_notes/llc-formation.mdx",
"project/rentearth/_graph/legal-document-model.mdx",
Expand All @@ -167,11 +174,9 @@
"project/rentearth/_notes/NotesGlob.astro",
"project/rentearth/_notes/glob.astro",
"project/rentearth/_notes",
"project/rentearth/_graph/support.mdx",
"application/automation/_notes-n8n/n8n-supabase.md",
"application/automation/_notes/n8n-supabase.md",
"journal/08-15.md",
"journal/08-16.md",
"journal/08-14.md",
"journal/08-13.md",
"theory/bizops/_graph/business-model.md",
Expand All @@ -187,11 +192,6 @@
"journal/08-10.md",
"journal/08-09.md",
"application/n8n/_notes/n8n-supabase.md",
"application/n8n/_notes/supabase-cache.md",
"application/n8n/_examples/supabase-cache.md",
"journal/08-08.md",
"journal/08-07.md",
"application/obs/_notes/voicemeter.md",
"application/obs/notes/voicemeter.md"
"application/n8n/_notes/supabase-cache.md"
]
}
18 changes: 18 additions & 0 deletions src/content/application/appwrite/_notes/NotesGlob.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
const notes = await Astro.glob('./*.md*');
import MDXJS from '@w/MDXJS.astro';
---
{
notes.map((note) => (
<MDXJS transparent={false}>
<div>
<article class="">
<h2>{note.frontmatter.title}</h2>
<p>{note.frontmatter.description}</p>

<note.Content />
</article>
</div>
</MDXJS>
))
}
29 changes: 29 additions & 0 deletions src/content/application/appwrite/_notes/appwrite_notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: Notes
description: General Appwrite Notes
---

## Notes

These will be all the notes for AppWrite, as we migrate over to it.

### Log

- [ ] Add Guides for AppWrite
- [ ] Add Videos for AppWrite

#### Journal

##### 2023-04-14

Added email configuration to the appwrite server variables.

##### 2023-04-12

Starting the mdx sheet for AppWrite. I will try to include all the reference material here.

### License

#### Appwrite License

Appwrite / appwrite is licensed under the BSD 3-Clause "New" or "Revised" License located here [license.md](https://github.com/appwrite/appwrite/blob/master/LICENSE)
19 changes: 19 additions & 0 deletions src/content/application/appwrite/_sdk/SDKGlob.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
const sdk = await Astro.glob('./*.md*');
import MDXJS from '@w/MDXJS.astro';
---

{
sdk.map((graph) => (
<MDXJS transparent={false}>
<div>
<article class="">
<h2>{graph.frontmatter.title}</h2>
<p>{graph.frontmatter.description}</p>

<graph.Content />
</article>
</div>
</MDXJS>
))
}
135 changes: 135 additions & 0 deletions src/content/application/appwrite/_sdk/appwrite-functions.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
---
title: Appwrite Functions
description: Appwrite Function Documentation
---

## Functions

We split the functions into three different areas:

1. `Init` - Which initializes the serverless function, handling the installs if using different libaries, ect...
2. `Core` - These are the notes for the core serverless function.
3. `Extra` - Additional notes and information regarding the expansion of a serverless function.

### Init

Hello there, fellow developers! 🚀

Today, we're diving deep into the world of cloud functions with a special focus on Appwrite - a wonderful platform that allows you to build secure web and mobile applications faster.

#### What is a Cloud Function?

At its core, a cloud function is a piece of code that runs in response to an event.
You don’t need to manage the infrastructure; the cloud provider does that for you.
Think of it as "Function as a Service" (FaaS).
Cloud functions are a key part of the serverless architecture, allowing developers to focus on writing code without worrying about the underlying infrastructure.

#### Initializing Your Appwrite Cloud Function

1. `Function Creation` :
- Head over to your Appwrite Console, navigate to the Functions section, and click on `Add Function`.
- Give your function a name and choose a runtime (e.g., Node.js, Python, Deno, etc.).

2. `Code Your Function` :
- Reference Core for the basics.
- Here is a basic / starter.

```javascript
module.exports = async (req, res) => {
const payload =
req.payload ||
'No payload provided. Add custom data when executing function.';

const secretKey =
req.variables.SECRET_KEY ||
'SECRET_KEY variable not found. You can set it in Function settings.';

const randomNumber = Math.random();

const trigger = req.variables.APPWRITE_FUNCTION_TRIGGER;

res.json({
message: 'Hello from Appwrite!',
payload,
secretKey,
randomNumber,
trigger,
});
};

```
3. `Packaging` :
- Cloud functions in Appwrite run inside Docker containers, so your function and any dependencies need to be packed into a tarball. For Node.js:
`tar -czf code.tar.gz --exclude code.tar.gz .`

4. `Deployment` :
- Upload Your Code: Back in the Appwrite Console, under your function, click on the Deploy Tag button.
- Upload the code.tar.gz file.
- Set Your Triggers! Functions can respond to various events, like user registration or document creation. Select the triggers relevant to your use case.
- Execute! With everything set, hit the Execute button. Your function will run, and you can see the logs in real-time.

Yay! Congratulations, you’ve just deployed your first Appwrite Cloud Function! 🎉
The power of serverless lies in its simplicity and scalability.
As your application grows, you can continue adding more functions without the hassle of managing servers or infrastructure.

I hope this introduction helps kickstart your journey with Appwrite Cloud Functions.
Stay tuned for more in-depth tutorials, and happy coding! 🚀


### Core

General documentation and information in reference to the cloud functions / open runtime for Appwrite.

Remember to import the SDK outside of the module function.

The main `module.exports` is usually written like this

```javascript
module.exports = async function (req, res) {}; // Passing req and res
```

The `req` contains these three main objects:

`req.headers` - An object with the request headers for the function.
`req.payload` - An object with the payload, which is the main body data.
`req.env` - An object with the environment data.

The `res` can return two main objects:

`res.send` - returns a `text` and `statusCode`.
`res.json` - returns an `object` and `statusCode`.

Example of parsing the `req.payload` check and `res.json` return.

```javascript
if (req.payload) {
try {
payload = JSON.parse(req.payload);
} catch (error) {
errorHandler('Corrupt payload for the function.');
}
} else {
errorHandler('Missing payload for the function.');
}
```

In this case our `errorHandler` function would be:

```javascript
const errorHandler = (__errorMessage, statusCode = 418) => {
res.json({ data: 'error', message: __errorMessage }, statusCode);
};
```

### Extra

In the context of Appwrite Cloud Functions, "extra libraries" refer to external dependencies or packages that your function might need to execute correctly.
Due to the isolated nature of cloud functions, they don't inherently have access to all the libraries or tools available in a full-fledged server environment.
To overcome this, Appwrite allows you to bundle these additional libraries with your function code.
When you're developing your function, you specify and package these libraries—be it npm packages for a Node.js function, pip packages for a Python function, or any other dependencies for other runtimes.
Once bundled, Appwrite ensures that these libraries are available to your function at runtime, providing a seamless execution environment tailored to your specific needs.

#### PoC

- For data fetching, we recommend that you add an external module known as `axios`.
- `const axios = require("axios").default;`
27 changes: 27 additions & 0 deletions src/content/application/appwrite/_sdk/appwrite-sdk.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: Appwrite SDK
description: Appwrite SDK Notes and Information
---

## SDK


```javascript
const sdk = require('node-appwrite');
```

Then to call it from inside the `module.exports` if you want to use it as a function.

```javascript
const client = new sdk.Client();

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 health = 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);
```
Loading

0 comments on commit 01e3eea

Please sign in to comment.