Skip to content

Commit e69c022

Browse files
committed
update: optimize assistant, size, reference downloading and bump examples!
1 parent a85bd2f commit e69c022

7 files changed

+170
-308
lines changed

Dockerfile

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
FROM node:18-alpine AS base
1+
FROM node:18-slim AS base
22

3-
RUN apk add --no-cache \
4-
python3 \
5-
make \
6-
g++ \
7-
build-base \
8-
git
3+
RUN apt-get update && apt-get install -y python3 make g++ git
94

105
ENV PNPM_HOME="/pnpm"
116
ENV PATH="$PNPM_HOME:$PATH"
@@ -14,14 +9,12 @@ RUN corepack prepare [email protected] --activate
149

1510
FROM base AS builder
1611

17-
COPY package.json pnpm-lock.yaml /usr/src/app/
1812
WORKDIR /usr/src/app
1913

20-
RUN pnpm fetch --prod
14+
COPY package.json pnpm-lock.yaml ./
15+
RUN pnpm install --frozen-lockfile --prod
2116

22-
COPY . /usr/src/app
23-
24-
RUN pnpm install
17+
COPY . .
2518

2619
ARG _BUILD_GIT_URL
2720
ARG _BUILD_GIT_BRANCH
@@ -35,7 +28,14 @@ ENV _BUILD_WEBSITE_VERSION=${_BUILD_WEBSITE_VERSION}
3528

3629
RUN pnpm run fetch-sources
3730

38-
FROM base
31+
FROM node:18-slim AS prod
32+
33+
ENV NODE_ENV=production
34+
ENV PNPM_HOME="/pnpm"
35+
ENV PATH="$PNPM_HOME:$PATH"
36+
37+
RUN corepack enable
38+
RUN corepack prepare [email protected] --activate
3939

4040
WORKDIR /usr/src/app
4141

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"dev": "nodemon src/main.js",
1010
"lint": "eslint src",
1111
"format": "prettier --write \"src/**/*.js\" \"scripts/**/*.js\"",
12-
"fetch-sources": "node scripts/git-sources.js && node scripts/web-sources.js"
12+
"fetch-sources": "node scripts/git-sources.js && node scripts/web-sources.js",
13+
"make-sources": "node scripts/web-sources.js"
1314
},
1415
"keywords": [],
1516
"author": "",

scripts/web-sources.js

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const SDKS = [
4040
"server-graphql",
4141
"server-rest",
4242
];
43+
4344
const SERVICES = [
4445
"account",
4546
"avatars",
@@ -55,37 +56,48 @@ const SERVICES = [
5556
await execa("rm", ["-rf", LOCAL_PATH]);
5657
await mkdir(LOCAL_PATH, { recursive: true });
5758

58-
console.log("Downloading reference pages...");
59+
await Promise.all(
60+
SDKS.map((sdk) => {
61+
return mkdir(`${LOCAL_PATH}/${sdk}/`, { recursive: true });
62+
}),
63+
);
5964

60-
for (const sdk of SDKS) {
61-
await mkdir(`./sources/references/${sdk}/`, { recursive: true });
65+
console.log("Downloading reference pages...");
6266

63-
for (const service of SERVICES) {
64-
const url = new URL(
65-
`/docs/references/${WEBSITE_VERSION}/${sdk}/${service}`,
66-
WEBSITE_URL,
67-
);
67+
const start = Date.now();
6868

69-
const response = await fetch(url.toString());
69+
await Promise.all(
70+
SDKS.flatMap((sdk) =>
71+
SERVICES.map(async (service) => {
72+
const url = new URL(
73+
`/docs/references/${WEBSITE_VERSION}/${sdk}/${service}`,
74+
WEBSITE_URL,
75+
);
7076

71-
const html = await response.text();
72-
if (!html) {
73-
console.warn(`Skipping page ${url} - no content found`);
74-
continue;
75-
}
77+
try {
78+
const response = await fetch(url.toString());
79+
const html = await response.text();
80+
if (!html) {
81+
console.warn(`Skipping page ${url} - no content found`);
82+
return;
83+
}
7684

77-
// Ignore the header and footer
78-
const matches = html.match(
79-
/<main class="contents" id="main">(.*?)<\/main>/s,
80-
);
81-
if (!matches || !matches[0]) {
82-
console.warn(`Skipping page ${url} - no <main> tag found`);
83-
continue;
84-
}
85+
const matches = html.match(
86+
/<main class="contents" id="main">(.*?)<\/main>/s,
87+
);
88+
if (!matches || !matches[0]) {
89+
console.warn(`Skipping page ${url} - no <main> tag found`);
90+
return;
91+
}
8592

86-
const markdown = NodeHtmlMarkdown.translate(matches[0]);
93+
const markdown = NodeHtmlMarkdown.translate(matches[0]);
94+
await writeFile(`${LOCAL_PATH}/${sdk}/${service}.md`, markdown);
95+
console.log(`Created ./sources/references/${sdk}/${service}.md`);
96+
} catch (e) {
97+
console.warn(`Failed to download ${url}:`, e);
98+
}
99+
}),
100+
),
101+
);
87102

88-
await writeFile(`./sources/references/${sdk}/${service}.md`, markdown);
89-
console.log(`Created ./sources/references/${sdk}/${service}.md`);
90-
}
91-
}
103+
console.log("References created in", (Date.now() - start) / 1000, "seconds");
Lines changed: 19 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,34 @@
1-
To create a new user with Dart using the Appwrite Users API, you can use one of the provided methods depending on the hashing algorithm you want to use for the password. Below are examples for creating a user with different hashing algorithms:
1+
To create a new user using the Appwrite Users API with Dart, you can use the `create` method from the `Users` class. Below is an example of how to do this:
22

3-
### Using PHPass
43
```dart
54
import 'package:dart_appwrite/dart_appwrite.dart';
65
76
Client client = Client()
8-
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
7+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
98
.setProject('<YOUR_PROJECT_ID>') // Your project ID
109
.setKey('<YOUR_API_KEY>'); // Your secret API key
1110
1211
Users users = Users(client);
1312
14-
User result = await users.createPHPassUser(
15-
userId: '<USER_ID>',
16-
17-
password: 'password',
18-
name: '<NAME>', // (optional)
19-
);
13+
Future<void> createUser() async {
14+
try {
15+
User result = await users.create(
16+
userId: '<USER_ID>',
17+
email: '[email protected]', // (optional)
18+
phone: '+12065550100', // (optional)
19+
password: '', // (optional)
20+
name: '<NAME>', // (optional)
21+
);
22+
print('User created: ${result.$id}');
23+
} catch (e) {
24+
print('Error creating user: $e');
25+
}
26+
}
27+
28+
createUser();
2029
```
2130

22-
### Using Scrypt
23-
```dart
24-
import 'package:dart_appwrite/dart_appwrite.dart';
25-
26-
Client client = Client()
27-
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
28-
.setProject('<YOUR_PROJECT_ID>') // Your project ID
29-
.setKey('<YOUR_API_KEY>'); // Your secret API key
30-
31-
Users users = Users(client);
32-
33-
User result = await users.createScryptUser(
34-
userId: '<USER_ID>',
35-
36-
password: 'password',
37-
passwordSalt: '<PASSWORD_SALT>',
38-
passwordCpu: 0,
39-
passwordMemory: 0,
40-
passwordParallel: 0,
41-
passwordLength: 0,
42-
name: '<NAME>', // (optional)
43-
);
44-
```
45-
46-
### Using Bcrypt
47-
```dart
48-
import 'package:dart_appwrite/dart_appwrite.dart';
49-
50-
Client client = Client()
51-
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
52-
.setProject('<YOUR_PROJECT_ID>') // Your project ID
53-
.setKey('<YOUR_API_KEY>'); // Your secret API key
54-
55-
Users users = Users(client);
56-
57-
User result = await users.createBcryptUser(
58-
userId: '<USER_ID>',
59-
60-
password: 'password',
61-
name: '<NAME>', // (optional)
62-
);
63-
```
64-
65-
### Using Scrypt Modified
66-
```dart
67-
import 'package:dart_appwrite/dart_appwrite.dart';
68-
69-
Client client = Client()
70-
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
71-
.setProject('<YOUR_PROJECT_ID>') // Your project ID
72-
.setKey('<YOUR_API_KEY>'); // Your secret API key
73-
74-
Users users = Users(client);
75-
76-
User result = await users.createScryptModifiedUser(
77-
userId: '<USER_ID>',
78-
79-
password: 'password',
80-
passwordSalt: '<PASSWORD_SALT>',
81-
passwordSaltSeparator: '<PASSWORD_SALT_SEPARATOR>',
82-
passwordSignerKey: '<PASSWORD_SIGNER_KEY>',
83-
name: '<NAME>', // (optional)
84-
);
85-
```
86-
87-
### Using Argon2
88-
```dart
89-
import 'package:dart_appwrite/dart_appwrite.dart';
90-
91-
Client client = Client()
92-
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
93-
.setProject('<YOUR_PROJECT_ID>') // Your project ID
94-
.setKey('<YOUR_API_KEY>'); // Your secret API key
95-
96-
Users users = Users(client);
97-
98-
User result = await users.createArgon2User(
99-
userId: '<USER_ID>',
100-
101-
password: 'password',
102-
name: '<NAME>', // (optional)
103-
);
104-
```
105-
106-
Replace `<YOUR_PROJECT_ID>`, `<YOUR_API_KEY>`, `<USER_ID>`, `<PASSWORD_SALT>`, `<PASSWORD_SALT_SEPARATOR>`, and `<PASSWORD_SIGNER_KEY>` with your actual Appwrite project details and user-specific information.
31+
In this example, replace `<REGION>`, `<YOUR_PROJECT_ID>`, `<YOUR_API_KEY>`, `<USER_ID>`, and other placeholders with your actual Appwrite project details and user information. The `create` method allows you to specify optional parameters such as `email`, `phone`, `password`, and `name`.
10732

10833
Sources:
10934
- https://appwrite.io/docs/references/cloud/server-dart/users
Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
To add a custom ___domain in the Appwrite Console, follow these steps:
22

3-
1. **Navigate to the Appwrite Console and go to your project.**
4-
2. **Click on the Settings tab in the left sidebar.**
5-
3. **Select the Custom domains section and click Create ___domain.**
6-
4. **Add your ___domain, and copy the associated CNAME record to your DNS provider.** You can refer to the [Add a CNAME record](https://appwrite.io/docs/advanced/platform/custom-domains/##cname-record) section for more details.
7-
5. **Verify your ___domain.** Note that DNS changes might take up to 48 hours to propagate worldwide, so you may not be able to complete this step on the same day.
8-
6. **Once you verify your ___domain, you can generate an SSL certificate.**
3+
1. Go to the Appwrite Console and navigate to your project.
4+
2. Click on the **Settings** tab in the left sidebar.
5+
3. Select the **Custom domains** section and click **Create ___domain**.
6+
4. Add your ___domain, and copy the associated CNAME record to your DNS provider. Refer to the [Add a CNAME record](https://appwrite.io/docs/advanced/platform/custom-domains/##cname-record) section for more details.
7+
5. Verify your ___domain. Keep in mind that DNS changes might take up to 48 hours to propagate worldwide, so you may not be able to complete this step immediately.
8+
6. Once your ___domain is verified, you can generate an SSL certificate.
99

10-
When both **VERIFICATION STATUS** and **CERTIFICATE STATUS** are green, the new ___domain is ready to use.
11-
12-
If you encounter any issues during the setup process or have questions, don't hesitate to [contact Appwrite support](https://appwrite.io/docs/advanced/platform/custom-domains/#/contact-us), and they will be happy to assist you.
10+
After completing these steps, your Appwrite project will be able to accept API requests from your custom ___domain. If you encounter any issues during the setup process or have questions, you can [contact Appwrite support](https://appwrite.io/docs/advanced/platform/custom-domains/#/contact-us) for assistance.
1311

1412
Sources:
1513
- https://appwrite.io/docs/products/functions/domains/
1614
- https://appwrite.io/docs/advanced/platform/custom-domains/
17-
- https://appwrite.io/docs/products/messaging/mailgun/
18-
- https://appwrite.io/docs/tutorials/subscriptions-with-stripe/step-3/
19-
- https://appwrite.io/docs/tutorials/subscriptions-with-stripe/step-4/
15+
- https://appwrite.io/docs/products/sites/domains/
16+
- https://appwrite.io/docs/products/network/dns/
17+
- https://appwrite.io/docs/products/sites/migrations/vercel/

0 commit comments

Comments
 (0)