Skip to content

Commit 05fdd33

Browse files
Merge pull request #304 from appwrite/feat-dynamic-keys
Feat: Use dynamic keys in url shorter
2 parents 46cda7a + 4d1f040 commit 05fdd33

112 files changed

Lines changed: 143 additions & 886 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bun/sync-with-meilisearch/README.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@ Sample `204` Response: No content.
2828

2929
## 🔒 Environment Variables
3030

31-
### APPWRITE_API_KEY
32-
33-
API Key to talk to Appwrite backend APIs.
34-
35-
| Question | Answer |
36-
| ------------- | ------------------------------------------------------------------------------------------- |
37-
| Required | Yes |
38-
| Sample Value | `d1efb...aec35` |
39-
| Documentation | [Appwrite: Getting Started for Server](https://appwrite.io/docs/advanced/platform/api-keys) |
40-
4131
### APPWRITE_DATABASE_ID
4232

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

61-
### APPWRITE_ENDPOINT
62-
63-
The URL endpoint of the Appwrite server. If not provided, it defaults to the Appwrite Cloud server: `https://cloud.appwrite.io/v1`.
64-
65-
| Question | Answer |
66-
| ------------ | ------------------------------ |
67-
| Required | No |
68-
| Sample Value | `https://cloud.appwrite.io/v1` |
69-
7051
### MEILISEARCH_ENDPOINT
7152

7253
The host URL of the Meilisearch server.

bun/sync-with-meilisearch/env.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
declare module "bun" {
22
interface Env {
3-
APPWRITE_ENDPOINT?: string;
4-
APPWRITE_API_KEY: string;
3+
APPWRITE_FUNCTION_API_ENDPOINT: string;
54
APPWRITE_FUNCTION_PROJECT_ID: string;
65
APPWRITE_DATABASE_ID: string;
76
APPWRITE_COLLECTION_ID: string;

bun/sync-with-meilisearch/src/main.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { MeiliSearch } from "meilisearch";
44

55
export default async ({ req, res, log }) => {
66
throwIfMissing(Bun.env, [
7-
"APPWRITE_API_KEY",
87
"APPWRITE_DATABASE_ID",
98
"APPWRITE_COLLECTION_ID",
109
"MEILISEARCH_ENDPOINT",
@@ -24,9 +23,9 @@ export default async ({ req, res, log }) => {
2423
}
2524

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

3130
const databases = new Databases(client);
3231

bun/sync-with-qdrant/README.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,6 @@ Triggers sync of the Appwrite database collection to Qdrant.
2424

2525
## 🔒 Environment Variables
2626

27-
### APPWRITE_API_KEY
28-
29-
API Key to talk to Appwrite backend APIs.
30-
31-
| Question | Answer |
32-
| ------------- | -------------------------------------------------------------------------------------------------- |
33-
| Required | Yes |
34-
| Sample Value | `d1efb...aec35` |
35-
| Documentation | [Appwrite: Getting Started for Server](https://appwrite.io/docs/getting-started-for-server#apiKey) |
36-
3727
### APPWRITE_DATABASE_ID
3828

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

57-
### APPWRITE_ENDPOINT
58-
59-
The URL endpoint of the Appwrite server. If not provided, it defaults to the Appwrite Cloud server: `https://cloud.appwrite.io/v1`.
60-
61-
| Question | Answer |
62-
| ------------ | ------------------------------ |
63-
| Required | No |
64-
| Sample Value | `https://cloud.appwrite.io/v1` |
65-
6647
### QDRANT_URL
6748

6849
The URL of the Qdrant server.

bun/sync-with-qdrant/env.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
declare module "bun" {
22
interface Env {
3-
APPWRITE_ENDPOINT?: string;
4-
APPWRITE_API_KEY: string;
3+
APPWRITE_FUNCTION_API_ENDPOINT: string;
54
APPWRITE_FUNCTION_PROJECT_ID: string;
65
APPWRITE_DATABASE_ID: string;
76
APPWRITE_COLLECTION_ID: string;

bun/sync-with-qdrant/src/appwrite.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ import { Client, Databases, Query } from 'node-appwrite';
33
class AppwriteService {
44
databases: Databases;
55

6-
constructor() {
6+
constructor(apiKey: string) {
77
const client = new Client();
88
client
9-
.setEndpoint(
10-
process.env.APPWRITE_ENDPOINT ?? 'https://cloud.appwrite.io/v1'
11-
)
9+
.setEndpoint(process.env.APPWRITE_FUNCTION_API_ENDPOINT)
1210
.setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID)
13-
.setKey(process.env.APPWRITE_API_KEY);
11+
.setKey(apiKey);
1412

1513
this.databases = new Databases(client);
1614
}

bun/sync-with-qdrant/src/main.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import AppwriteService from './appwrite.js';
55

66
export default async ({ req, res, log }: Context) => {
77
throwIfMissing(process.env, [
8-
'APPWRITE_API_KEY',
98
'APPWRITE_DATABASE_ID',
109
'APPWRITE_COLLECTION_ID',
1110
'QDRANT_URL',
@@ -51,7 +50,7 @@ export default async ({ req, res, log }: Context) => {
5150
}
5251

5352
log('Fetching documents from Appwrite...');
54-
const appwrite = new AppwriteService();
53+
const appwrite = new AppwriteService(req.headers['x-appwrite-key'] ?? '');
5554
const documents = await appwrite.getAllDocuments(
5655
process.env.APPWRITE_DATABASE_ID,
5756
process.env.APPWRITE_COLLECTION_ID

deno/sync-with-meilisearch/README.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@ Sample `204` Response: No content.
2828

2929
## 🔒 Environment Variables
3030

31-
### APPWRITE_API_KEY
32-
33-
API Key to talk to Appwrite backend APIs.
34-
35-
| Question | Answer |
36-
| ------------- | ------------------------------------------------------------------------------------------- |
37-
| Required | Yes |
38-
| Sample Value | `d1efb...aec35` |
39-
| Documentation | [Appwrite: Getting Started for Server](https://appwrite.io/docs/advanced/platform/api-keys) |
40-
4131
### APPWRITE_DATABASE_ID
4232

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

61-
### APPWRITE_ENDPOINT
62-
63-
The URL endpoint of the Appwrite server. If not provided, it defaults to the Appwrite Cloud server: `https://cloud.appwrite.io/v1`.
64-
65-
| Question | Answer |
66-
| ------------ | ------------------------------ |
67-
| Required | No |
68-
| Sample Value | `https://cloud.appwrite.io/v1` |
69-
7051
### MEILISEARCH_ENDPOINT
7152

7253
The host URL of the Meilisearch server.

deno/sync-with-meilisearch/src/main.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { MeiliSearch } from "https://esm.sh/meilisearch@0.35.0";
88

99
export default async ({ req, res, log, error }: any) => {
1010
throwIfMissing(Deno.env.toObject(), [
11-
"APPWRITE_API_KEY",
1211
"APPWRITE_DATABASE_ID",
1312
"APPWRITE_COLLECTION_ID",
1413
"MEILISEARCH_ENDPOINT",
@@ -30,11 +29,9 @@ export default async ({ req, res, log, error }: any) => {
3029
}
3130

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

3936
const databases = new Databases(client);
4037

kotlin/sync-with-meilisearch/README.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,6 @@ Sample `204` Response: No content.
2727

2828
## 🔒 Environment Variables
2929

30-
### APPWRITE_API_KEY
31-
32-
API Key to talk to Appwrite backend APIs.
33-
34-
| Question | Answer |
35-
| ------------- | ------------------------------------------------------------------------------------------- |
36-
| Required | Yes |
37-
| Sample Value | `d1efb...aec35` |
38-
| Documentation | [Appwrite: Getting Started for Server](https://appwrite.io/docs/advanced/platform/api-keys) |
39-
4030
### APPWRITE_DATABASE_ID
4131

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

60-
### APPWRITE_ENDPOINT
61-
62-
The URL endpoint of the Appwrite server. If not provided, it defaults to the Appwrite Cloud server: `https://cloud.appwrite.io/v1`.
63-
64-
| Question | Answer |
65-
| ------------ | ------------------------------ |
66-
| Required | No |
67-
| Sample Value | `https://cloud.appwrite.io/v1` |
68-
6950
### MEILISEARCH_ENDPOINT
7051

7152
The host URL of the Meilisearch server.

0 commit comments

Comments
 (0)