Skip to content

Commit

Permalink
Merge pull request #304 from appwrite/feat-dynamic-keys
Browse files Browse the repository at this point in the history
Feat: Use dynamic keys in url shorter
  • Loading branch information
christyjacob4 authored Aug 20, 2024
2 parents 46cda7a + 4d1f040 commit 05fdd33
Show file tree
Hide file tree
Showing 112 changed files with 143 additions and 886 deletions.
19 changes: 0 additions & 19 deletions bun/sync-with-meilisearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@ Sample `204` Response: No content.

## 🔒 Environment Variables

### APPWRITE_API_KEY

API Key to talk to Appwrite backend APIs.

| Question | Answer |
| ------------- | ------------------------------------------------------------------------------------------- |
| Required | Yes |
| Sample Value | `d1efb...aec35` |
| Documentation | [Appwrite: Getting Started for Server](https://appwrite.io/docs/advanced/platform/api-keys) |

### APPWRITE_DATABASE_ID

The ID of the Appwrite database that contains the collection to sync.
Expand All @@ -58,15 +48,6 @@ The ID of the collection in the Appwrite database to sync.
| Sample Value | `7c3e8...2a9f1` |
| Documentation | [Appwrite: Collections](https://appwrite.io/docs/products/databases/collections) |

### APPWRITE_ENDPOINT

The URL endpoint of the Appwrite server. If not provided, it defaults to the Appwrite Cloud server: `https://cloud.appwrite.io/v1`.

| Question | Answer |
| ------------ | ------------------------------ |
| Required | No |
| Sample Value | `https://cloud.appwrite.io/v1` |

### MEILISEARCH_ENDPOINT

The host URL of the Meilisearch server.
Expand Down
3 changes: 1 addition & 2 deletions bun/sync-with-meilisearch/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
declare module "bun" {
interface Env {
APPWRITE_ENDPOINT?: string;
APPWRITE_API_KEY: string;
APPWRITE_FUNCTION_API_ENDPOINT: string;
APPWRITE_FUNCTION_PROJECT_ID: string;
APPWRITE_DATABASE_ID: string;
APPWRITE_COLLECTION_ID: string;
Expand Down
5 changes: 2 additions & 3 deletions bun/sync-with-meilisearch/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { MeiliSearch } from "meilisearch";

export default async ({ req, res, log }) => {
throwIfMissing(Bun.env, [
"APPWRITE_API_KEY",
"APPWRITE_DATABASE_ID",
"APPWRITE_COLLECTION_ID",
"MEILISEARCH_ENDPOINT",
Expand All @@ -24,9 +23,9 @@ export default async ({ req, res, log }) => {
}

const client = new Client()
.setEndpoint(Bun.env.APPWRITE_ENDPOINT ?? "https://cloud.appwrite.io/v1")
.setEndpoint(Bun.env.APPWRITE_FUNCTION_API_ENDPOINT)
.setProject(Bun.env.APPWRITE_FUNCTION_PROJECT_ID)
.setKey(Bun.env.APPWRITE_API_KEY);
.setKey(req.headers['x-appwrite-key'] ?? '');

const databases = new Databases(client);

Expand Down
19 changes: 0 additions & 19 deletions bun/sync-with-qdrant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@ Triggers sync of the Appwrite database collection to Qdrant.

## 🔒 Environment Variables

### APPWRITE_API_KEY

API Key to talk to Appwrite backend APIs.

| Question | Answer |
| ------------- | -------------------------------------------------------------------------------------------------- |
| Required | Yes |
| Sample Value | `d1efb...aec35` |
| Documentation | [Appwrite: Getting Started for Server](https://appwrite.io/docs/getting-started-for-server#apiKey) |

### APPWRITE_DATABASE_ID

The ID of the Appwrite database that contains the collection to sync.
Expand All @@ -54,15 +44,6 @@ The ID of the collection in the Appwrite database to sync.
| Sample Value | `7c3e8...2a9f1` |
| Documentation | [Appwrite: Collections](https://appwrite.io/docs/databases#collection) |

### APPWRITE_ENDPOINT

The URL endpoint of the Appwrite server. If not provided, it defaults to the Appwrite Cloud server: `https://cloud.appwrite.io/v1`.

| Question | Answer |
| ------------ | ------------------------------ |
| Required | No |
| Sample Value | `https://cloud.appwrite.io/v1` |

### QDRANT_URL

The URL of the Qdrant server.
Expand Down
3 changes: 1 addition & 2 deletions bun/sync-with-qdrant/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
declare module "bun" {
interface Env {
APPWRITE_ENDPOINT?: string;
APPWRITE_API_KEY: string;
APPWRITE_FUNCTION_API_ENDPOINT: string;
APPWRITE_FUNCTION_PROJECT_ID: string;
APPWRITE_DATABASE_ID: string;
APPWRITE_COLLECTION_ID: string;
Expand Down
8 changes: 3 additions & 5 deletions bun/sync-with-qdrant/src/appwrite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ import { Client, Databases, Query } from 'node-appwrite';
class AppwriteService {
databases: Databases;

constructor() {
constructor(apiKey: string) {
const client = new Client();
client
.setEndpoint(
process.env.APPWRITE_ENDPOINT ?? 'https://cloud.appwrite.io/v1'
)
.setEndpoint(process.env.APPWRITE_FUNCTION_API_ENDPOINT)
.setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID)
.setKey(process.env.APPWRITE_API_KEY);
.setKey(apiKey);

this.databases = new Databases(client);
}
Expand Down
3 changes: 1 addition & 2 deletions bun/sync-with-qdrant/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import AppwriteService from './appwrite.js';

export default async ({ req, res, log }: Context) => {
throwIfMissing(process.env, [
'APPWRITE_API_KEY',
'APPWRITE_DATABASE_ID',
'APPWRITE_COLLECTION_ID',
'QDRANT_URL',
Expand Down Expand Up @@ -51,7 +50,7 @@ export default async ({ req, res, log }: Context) => {
}

log('Fetching documents from Appwrite...');
const appwrite = new AppwriteService();
const appwrite = new AppwriteService(req.headers['x-appwrite-key'] ?? '');
const documents = await appwrite.getAllDocuments(
process.env.APPWRITE_DATABASE_ID,
process.env.APPWRITE_COLLECTION_ID
Expand Down
19 changes: 0 additions & 19 deletions deno/sync-with-meilisearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@ Sample `204` Response: No content.

## 🔒 Environment Variables

### APPWRITE_API_KEY

API Key to talk to Appwrite backend APIs.

| Question | Answer |
| ------------- | ------------------------------------------------------------------------------------------- |
| Required | Yes |
| Sample Value | `d1efb...aec35` |
| Documentation | [Appwrite: Getting Started for Server](https://appwrite.io/docs/advanced/platform/api-keys) |

### APPWRITE_DATABASE_ID

The ID of the Appwrite database that contains the collection to sync.
Expand All @@ -58,15 +48,6 @@ The ID of the collection in the Appwrite database to sync.
| Sample Value | `7c3e8...2a9f1` |
| Documentation | [Appwrite: Collections](https://appwrite.io/docs/products/databases/collections) |

### APPWRITE_ENDPOINT

The URL endpoint of the Appwrite server. If not provided, it defaults to the Appwrite Cloud server: `https://cloud.appwrite.io/v1`.

| Question | Answer |
| ------------ | ------------------------------ |
| Required | No |
| Sample Value | `https://cloud.appwrite.io/v1` |

### MEILISEARCH_ENDPOINT

The host URL of the Meilisearch server.
Expand Down
7 changes: 2 additions & 5 deletions deno/sync-with-meilisearch/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { MeiliSearch } from "https://esm.sh/[email protected]";

export default async ({ req, res, log, error }: any) => {
throwIfMissing(Deno.env.toObject(), [
"APPWRITE_API_KEY",
"APPWRITE_DATABASE_ID",
"APPWRITE_COLLECTION_ID",
"MEILISEARCH_ENDPOINT",
Expand All @@ -30,11 +29,9 @@ export default async ({ req, res, log, error }: any) => {
}

const client = new Client()
.setEndpoint(
Deno.env.get("APPWRITE_ENDPOINT") ?? "https://cloud.appwrite.io/v1",
)
.setEndpoint(Deno.env.get("APPWRITE_FUNCTION_API_ENDPOINT") ?? "")
.setProject(Deno.env.get("APPWRITE_FUNCTION_PROJECT_ID") ?? "")
.setKey(Deno.env.get("APPWRITE_API_KEY") ?? "");
.setKey(req.headers['x-appwrite-key'] ?? "");

const databases = new Databases(client);

Expand Down
19 changes: 0 additions & 19 deletions kotlin/sync-with-meilisearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ Sample `204` Response: No content.

## 🔒 Environment Variables

### APPWRITE_API_KEY

API Key to talk to Appwrite backend APIs.

| Question | Answer |
| ------------- | ------------------------------------------------------------------------------------------- |
| Required | Yes |
| Sample Value | `d1efb...aec35` |
| Documentation | [Appwrite: Getting Started for Server](https://appwrite.io/docs/advanced/platform/api-keys) |

### APPWRITE_DATABASE_ID

The ID of the Appwrite database that contains the collection to sync.
Expand All @@ -57,15 +47,6 @@ The ID of the collection in the Appwrite database to sync.
| Sample Value | `7c3e8...2a9f1` |
| Documentation | [Appwrite: Collections](https://appwrite.io/docs/products/databases/collections) |

### APPWRITE_ENDPOINT

The URL endpoint of the Appwrite server. If not provided, it defaults to the Appwrite Cloud server: `https://cloud.appwrite.io/v1`.

| Question | Answer |
| ------------ | ------------------------------ |
| Required | No |
| Sample Value | `https://cloud.appwrite.io/v1` |

### MEILISEARCH_ENDPOINT

The host URL of the Meilisearch server.
Expand Down
5 changes: 2 additions & 3 deletions kotlin/sync-with-meilisearch/src/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class Main {
suspend fun main(context: RuntimeContext): RuntimeOutput {

Utils.throwIfMissing(System.getenv(), listOf(
"APPWRITE_API_KEY",
"APPWRITE_DATABASE_ID",
"APPWRITE_COLLECTION_ID",
"MEILISEARCH_ENDPOINT",
Expand All @@ -35,9 +34,9 @@ class Main {
}

val client = AppwriteClient().apply {
setEndpoint(System.getenv("APPWRITE_ENDPOINT") ?: "https://cloud.appwrite.io/v1")
setEndpoint(System.getenv("APPWRITE_FUNCTION_API_ENDPOINT"))
setProject(System.getenv("APPWRITE_FUNCTION_PROJECT_ID"))
setKey(System.getenv("APPWRITE_API_KEY"))
setKey(context.res.headers["x-appwrite-key"])
}

val databases = Databases(client)
Expand Down
19 changes: 0 additions & 19 deletions node-typescript/sync-with-meilisearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@ Sample `204` Response: No content.

## 🔒 Environment Variables

### APPWRITE_API_KEY

API Key to talk to Appwrite backend APIs.

| Question | Answer |
| ------------- | ------------------------------------------------------------------------------------------- |
| Required | Yes |
| Sample Value | `d1efb...aec35` |
| Documentation | [Appwrite: Getting Started for Server](https://appwrite.io/docs/advanced/platform/api-keys) |

### APPWRITE_DATABASE_ID

The ID of the Appwrite database that contains the collection to sync.
Expand All @@ -58,15 +48,6 @@ The ID of the collection in the Appwrite database to sync.
| Sample Value | `7c3e8...2a9f1` |
| Documentation | [Appwrite: Collections](https://appwrite.io/docs/products/databases/collections) |

### APPWRITE_ENDPOINT

The URL endpoint of the Appwrite server. If not provided, it defaults to the Appwrite Cloud server: `https://cloud.appwrite.io/v1`.

| Question | Answer |
| ------------ | ------------------------------ |
| Required | No |
| Sample Value | `https://cloud.appwrite.io/v1` |

### MEILISEARCH_ENDPOINT

The host URL of the Meilisearch server.
Expand Down
3 changes: 1 addition & 2 deletions node-typescript/sync-with-meilisearch/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
declare global {
namespace NodeJS {
interface ProcessEnv {
APPWRITE_ENDPOINT?: string;
APPWRITE_API_KEY: string;
APPWRITE_FUNCTION_API_ENDPOINT: string;
APPWRITE_FUNCTION_PROJECT_ID: string;
APPWRITE_DATABASE_ID: string;
APPWRITE_COLLECTION_ID: string;
Expand Down
7 changes: 2 additions & 5 deletions node-typescript/sync-with-meilisearch/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ type Context = {

export default async ({ req, res, log }: Context) => {
throwIfMissing(process.env, [
'APPWRITE_API_KEY',
'APPWRITE_DATABASE_ID',
'APPWRITE_COLLECTION_ID',
'MEILISEARCH_ENDPOINT',
Expand All @@ -31,11 +30,9 @@ export default async ({ req, res, log }: Context) => {
}

const client = new Client()
.setEndpoint(
process.env.APPWRITE_ENDPOINT ?? 'https://cloud.appwrite.io/v1'
)
.setEndpoint(process.env.APPWRITE_FUNCTION_API_ENDPOINT)
.setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID)
.setKey(process.env.APPWRITE_API_KEY);
.setKey(req.headers['x-appwrite-key'] ?? '');

const databases = new Databases(client);

Expand Down
19 changes: 0 additions & 19 deletions node-typescript/sync-with-qdrant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@ Triggers sync of the Appwrite database collection to Qdrant.

## 🔒 Environment Variables

### APPWRITE_API_KEY

API Key to talk to Appwrite backend APIs.

| Question | Answer |
| ------------- | -------------------------------------------------------------------------------------------------- |
| Required | Yes |
| Sample Value | `d1efb...aec35` |
| Documentation | [Appwrite: Getting Started for Server](https://appwrite.io/docs/getting-started-for-server#apiKey) |

### APPWRITE_DATABASE_ID

The ID of the Appwrite database that contains the collection to sync.
Expand All @@ -54,15 +44,6 @@ The ID of the collection in the Appwrite database to sync.
| Sample Value | `7c3e8...2a9f1` |
| Documentation | [Appwrite: Collections](https://appwrite.io/docs/databases#collection) |

### APPWRITE_ENDPOINT

The URL endpoint of the Appwrite server. If not provided, it defaults to the Appwrite Cloud server: `https://cloud.appwrite.io/v1`.

| Question | Answer |
| ------------ | ------------------------------ |
| Required | No |
| Sample Value | `https://cloud.appwrite.io/v1` |

### QDRANT_URL

The URL of the Qdrant server.
Expand Down
3 changes: 1 addition & 2 deletions node-typescript/sync-with-qdrant/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
declare global {
namespace NodeJS {
interface ProcessEnv {
APPWRITE_ENDPOINT?: string;
APPWRITE_API_KEY: string;
APPWRITE_FUNCTION_API_ENDPOINT: string;
APPWRITE_FUNCTION_PROJECT_ID: string;
APPWRITE_DATABASE_ID: string;
APPWRITE_COLLECTION_ID: string;
Expand Down
8 changes: 3 additions & 5 deletions node-typescript/sync-with-qdrant/src/appwrite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ import { Client, Databases, Query } from 'node-appwrite';
class AppwriteService {
databases: Databases;

constructor() {
constructor(apiKey) {
const client = new Client();
client
.setEndpoint(
process.env.APPWRITE_ENDPOINT ?? 'https://cloud.appwrite.io/v1'
)
.setEndpoint(process.env.APPWRITE_FUNCTION_API_ENDPOINT)
.setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID)
.setKey(process.env.APPWRITE_API_KEY);
.setKey(apiKey);

this.databases = new Databases(client);
}
Expand Down
3 changes: 1 addition & 2 deletions node-typescript/sync-with-qdrant/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import AppwriteService from './appwrite.js';

export default async ({ req, res, log }: Context) => {
throwIfMissing(process.env, [
'APPWRITE_API_KEY',
'APPWRITE_DATABASE_ID',
'APPWRITE_COLLECTION_ID',
'QDRANT_URL',
Expand Down Expand Up @@ -51,7 +50,7 @@ export default async ({ req, res, log }: Context) => {
}

log('Fetching documents from Appwrite...');
const appwrite = new AppwriteService();
const appwrite = new AppwriteService(req.headers['x-appwrite-key'] ?? '');
const documents = await appwrite.getAllDocuments(
process.env.APPWRITE_DATABASE_ID,
process.env.APPWRITE_COLLECTION_ID
Expand Down
Loading

0 comments on commit 05fdd33

Please sign in to comment.