Skip to content
This repository was archived by the owner on Jan 26, 2024. It is now read-only.

Commit 27e6395

Browse files
feat: update Appwrite to support 0.15.x (#42)
1 parent 0fd5ecf commit 27e6395

File tree

7 files changed

+32
-26
lines changed

7 files changed

+32
-26
lines changed

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
VITE_APP_ENDPOINT=
22
VITE_APP_PROJECT=
3-
VITE_APP_COLLECTION_ID=
3+
VITE_APP_COLLECTION_ID=
4+
VITE_APP_DATABASE_ID=

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ You have two options to deploy the front-end and we will cover both of them here
4343

4444
* VITE_APP_ENDPOINT - Your Appwrite endpoint
4545
* VITE_APP_PROJECT - Your Appwrite project ID
46-
* VITE_APP_COLLECTION_ID - Your Appwrite collection ID
46+
* VITE_APP_COLLECTION_ID - Your Appwrite collection ID
47+
* VITE_APP_DATABASE_ID - Your Appwrite database ID
4748

4849
### **Deploy to a Static Hosting Provider**
4950

netlify.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
[template.environment]
1111
VITE_APP_ENDPOINT = "Your Appwrite Server Endpoint"
1212
VITE_APP_PROJECT = "Your Appwrite project ID"
13-
VITE_APP_COLLECTION_ID = "Your Collection ID"
13+
VITE_APP_COLLECTION_ID = "Your Collection ID"
14+
VITE_APP_DATABASE_ID = "Your Database ID"

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"dependencies": {
2323
"@tailwindcss/forms": "^0.3.2",
24-
"appwrite": "^8.0.0",
24+
"appwrite": "^9.0.0",
2525
"svelte-spa-router": "^3.1.0",
2626
"tailwindcss": "^2.1.1"
2727
}

src/appwrite.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
import { Appwrite } from "appwrite";
1+
import { Client as Appwrite, Databases, Account } from 'appwrite';
22

33
const server = {
4-
endpoint: import.meta.env.VITE_APP_ENDPOINT.toString(),
5-
project: import.meta.env.VITE_APP_PROJECT.toString(),
6-
collection: import.meta.env.VITE_APP_COLLECTION_ID.toString()
7-
}
4+
endpoint: import.meta.env.VITE_APP_ENDPOINT.toString(),
5+
project: import.meta.env.VITE_APP_PROJECT.toString(),
6+
collection: import.meta.env.VITE_APP_COLLECTION_ID.toString(),
7+
database: import.meta.env.VITE_APP_DATABASE_ID.toString(),
8+
};
89

9-
const sdk = new Appwrite();
10+
const client = new Appwrite();
11+
const account = new Account(client);
12+
const database = new Databases(client, server.database);
13+
client.setEndpoint(server.endpoint).setProject(server.project);
1014

11-
sdk.setEndpoint(server.endpoint).setProject(server.project);
12-
13-
export {sdk, server};
15+
const sdk = { account, database };
16+
export { sdk, server };

src/store.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Models } from 'appwrite';
2-
import { get, writable } from "svelte/store";
3-
import { sdk, server } from "./appwrite";
2+
import { get, writable } from 'svelte/store';
3+
import { sdk, server } from './appwrite';
44

55
export type Todo = {
66
content: string;
@@ -10,7 +10,7 @@ export type Todo = {
1010
export type Alert = {
1111
color: string;
1212
message: string;
13-
}
13+
};
1414

1515
const createTodos = () => {
1616
const { subscribe, update, set } = writable<Todo[]>([]);
@@ -54,7 +54,7 @@ const createTodos = () => {
5454
const index = n.findIndex((t) => t.$id === todo.$id);
5555
n[index] = {
5656
...n[index],
57-
...<Todo>todo
57+
...(<Todo>todo),
5858
};
5959
return n;
6060
});
@@ -74,12 +74,12 @@ const createState = () => {
7474
return await sdk.account.create('unique()', email, password, name);
7575
},
7676
login: async (email: string, password: string) => {
77-
await sdk.account.createSession(email, password);
77+
await sdk.account.createEmailSession(email, password);
7878
const user = await sdk.account.get();
7979
state.init(user);
8080
},
8181
logout: async () => {
82-
await sdk.account.deleteSession("current");
82+
await sdk.account.deleteSession('current');
8383
},
8484
alert: async (alert: Alert) =>
8585
update((n) => {

0 commit comments

Comments
 (0)