Skip to content

Commit

Permalink
feat!: sdk version update, added node-appwrite dependencies & remove …
Browse files Browse the repository at this point in the history
…types re-export
  • Loading branch information
Hrdtr committed Apr 17, 2024
1 parent 5f519c3 commit a0ef2a5
Show file tree
Hide file tree
Showing 9 changed files with 3,564 additions and 3,183 deletions.
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
},
"dependencies": {
"@nuxt/kit": "^3.9.1",
"appwrite": "^13.0.1"
"appwrite": "^14.0.0",
"node-appwrite": "^12.0.1"
},
"devDependencies": {
"@nuxt/module-builder": "^0.5.5",
Expand All @@ -47,10 +48,10 @@
"@nuxtjs/eslint-config-typescript": "^12.1.0",
"changelogen": "^0.5.5",
"eslint": "^8.56.0",
"nuxt": "^3.9.1",
"release-it": "^17.0.1",
"typescript": "~5.2.2",
"vitest": "^1.1.3"
"nuxt": "^3.11.2",
"release-it": "^17.2.0",
"typescript": "~5.4.5",
"vitest": "^1.5.0"
},
"publishConfig": {
"access": "public"
Expand Down
45 changes: 25 additions & 20 deletions playground/app.vue
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
<script setup lang="ts">
import type { Models } from 'appwrite'
import { ref, onMounted } from 'vue'
import { /* useAsyncData, */ useAppwrite } from '#imports'
import { useAsyncData, useAppwrite } from '#imports'
const { account } = useAppwrite()
// const { data } = await useAsyncData(async () => {
// const response = await account.get()
// console.log(response)
// return response
// })
const { account, session } = useAppwrite()
const { data: userAsyncData } = await useAsyncData(async () => {
const response = await account.get()
console.info('useAsyncData response:', response)
return response
})
const user = ref<any>()
const getAccount = async () => {
const userClient = ref<Models.User<Models.Preferences>>()
onMounted(async () => {
const response = await account.get()
user.value = response
}
onMounted(getAccount)
console.info('onMounted response:', response)
userClient.value = response
})
const email = ref('')
const password = ref('')
const login = async () => {
const res = await account.createEmailSession(email.value, password.value)
await getAccount()
console.log(res)
const res = await account.createEmailPasswordSession(email.value, password.value)
session.set(res.secret)
const response = await account.get()
userClient.value = response
}
const logout = async () => {
const res = await account.deleteSession('current')
user.value = undefined
console.log(res)
await account.deleteSession('current')
session.unset()
userClient.value = undefined
}
</script>

<template>
<div>
<form v-if="!user" @submit.prevent="login">
<form v-if="!userClient && !userAsyncData" @submit.prevent="login">
<input v-model="email" placeholder="Email" type="email">
<input v-model="password" placeholder="Password" type="password">
<button>Login</button>
Expand All @@ -41,6 +43,9 @@ const logout = async () => {
Logout
</button>

<pre>{{ JSON.stringify(user, null, 2) }}</pre>
<pre>userClient</pre>
<pre>{{ JSON.stringify(userClient, null, 2) }}</pre>
<pre>userAsyncData</pre>
<pre>{{ JSON.stringify(userAsyncData, null, 2) }}</pre>
</div>
</template>
12 changes: 12 additions & 0 deletions playground/server/api/me.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useServerSideAppwrite } from '../../../src/module'
import { defineEventHandler } from '#build/types/nitro-imports'

export default defineEventHandler(async (event) => {
const { account } = useServerSideAppwrite(event).withSession()
try {
const user = await account.get()
return user
} catch (e) {
return null
}
})
Loading

0 comments on commit a0ef2a5

Please sign in to comment.