Skip to content

Commit

Permalink
chore: fix demo
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux committed Feb 7, 2024
1 parent f581166 commit 2c4b7fb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 23 deletions.
28 changes: 5 additions & 23 deletions _demo/pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
const { auth } = useHub()
const { user } = useUserSession()
</script>

<template>
Expand All @@ -9,32 +10,13 @@ const { auth } = useHub()
Todo List
</h3>
<UButton
v-if="!auth.user"
icon="i-simple-icons-github"
label="Login with GitHub"
color="black"
external
v-if="!user" icon="i-simple-icons-github" label="Login with GitHub" color="black" external
@click="auth.loginWith('github')"
/>
<div v-else class="space-x-2">
<UButton
to="/todos"
icon="i-heroicons-list-bullet"
label="Go to Todos"
color="black"
/>
<UButton
to="/notes"
icon="i-heroicons-pencil-square"
label="Go to Notes"
color="black"
/>
<UButton
to="/storage"
icon="i-heroicons-document"
label="Go to Storage"
color="black"
/>
<UButton to="/todos" icon="i-heroicons-list-bullet" label="Go to Todos" color="black" />
<UButton to="/notes" icon="i-heroicons-pencil-square" label="Go to Notes" color="black" />
<UButton to="/storage" icon="i-heroicons-document" label="Go to Storage" color="black" />
</div>
</template>
<p class="font-medium">
Expand Down
27 changes: 27 additions & 0 deletions _demo/server/api/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export default eventHandler(async (event) => {
const db = useDatabaseClient()
// return useProjectKV(projectUrl).getKeys()
// return await db.prepare("SELECT * from todos").all()
// return await db.prepare("SELECT * from todos").first()
// return await db.prepare("SELECT * from todos").raw()
// return await db.prepare("SELECT * from todos").run()
// return await db.exec('SELECT * from todos;')

const stmt = db.prepare('SELECT * from todos WHERE id = ?1')
// return {
// one: await stmt.bind(1).first(),
// three: await stmt.bind(3).first()
// }

// return db.batch([
// stmt.bind(1),
// stmt.bind(2)
// ])
return db.batch([
db.prepare('PRAGMA table_list'),
db.prepare('PRAGMA table_info(todos)'),
])

// return useProjectDatabase(projectUrl).all(sql`SELECT * from todos``)
// return {}
})
5 changes: 5 additions & 0 deletions _demo/server/plugins/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default defineNitroPlugin(() => {
hubHooks.hook('auth:provider', (_provider, { user }, sessionData) => {
sessionData.user = user
})
})

0 comments on commit 2c4b7fb

Please sign in to comment.