Skip to content

Commit 3538004

Browse files
committed
feat!: remove config, remove drizzle, export proxy utils
1 parent a814c49 commit 3538004

File tree

22 files changed

+116
-278
lines changed

22 files changed

+116
-278
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ The Nuxt Toolkit to create full-stack applications on the Edge.
44

55
## Features
66

7-
- Session management with secured & sealed cookie sessions
8-
- Create and query typed collections with `useDatabase()`
7+
- Session management with `useAuth(event)`
8+
- Query an SQLite database with `useDatabase()`
99
- Access key-value storage with `useKV()`
1010
- Store files with `useBlob()`
11-
- Edge configuration available with `getConfig()` and `useConfig()` (vue app)
1211

1312
## Blob
1413

@@ -95,7 +94,6 @@ export default eventHandler(event => {
9594
## Key-Value Storage
9695

9796
- useKV() -> process.env.KV binding
98-
- useConfig() -> process.env.KV with `_config` key
9997

10098
- useKV().setItem('public/')
10199

_demo/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"dependencies": {
1010
"@iconify-json/simple-icons": "^1.1.90",
1111
"@nuxt/ui": "^2.13.0",
12+
"drizzle-orm": "^0.29.3",
1213
"nuxt": "^3.10.0",
1314
"nuxt-hub": "latest"
1415
},

_demo/server/api/db-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { sqliteTable, integer, text } from 'drizzle-orm/sqlite-core'
22

33
export default defineEventHandler(async () => {
4-
const db = useDatabase()
4+
const db = useDB()
55

66
const tables = await db.all(sql`
77
SELECT

_demo/server/api/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default eventHandler(async (event) => {
2-
const db = useDatabaseClient()
2+
const db = useDatabase()
33
// return useProjectKV(projectUrl).getKeys()
44
// return await db.prepare("SELECT * from todos").all()
55
// return await db.prepare("SELECT * from todos").first()

_demo/server/api/todos/[id].delete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default eventHandler(async (event) => {
77
}).parse)
88

99
// List todos for the current user
10-
const deletedTodo = await useDatabase().delete(tables.todos).where(and(
10+
const deletedTodo = await useDB().delete(tables.todos).where(and(
1111
eq(tables.todos.id, Number(id)),
1212
eq(tables.todos.userId, session.user.id)
1313
)).returning().get()

_demo/server/api/todos/[id].patch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default eventHandler(async (event) => {
1010
}).parse)
1111

1212
// List todos for the current user
13-
const todo = await useDatabase().update(tables.todos).set({
13+
const todo = await useDB().update(tables.todos).set({
1414
completed
1515
}).where(and(
1616
eq(tables.todos.id, Number(id)),

_demo/server/api/todos/index.get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default eventHandler(async (event) => {
44
const session = await requireUserSession(event)
55

66
// List todos for the current user
7-
const todos = await useDatabase().select().from(tables.todos).where(eq(tables.todos.userId, session.user.id)).all()
7+
const todos = await useDB().select().from(tables.todos).where(eq(tables.todos.userId, session.user.id)).all()
88

99
return todos
1010
})

_demo/server/api/todos/index.post.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default eventHandler(async (event) => {
55
}).parse)
66

77
// List todos for the current user
8-
const todo = await useDatabase().insert(tables.todos).values({
8+
const todo = await useDB().insert(tables.todos).values({
99
userId: session.user.id,
1010
title,
1111
createdAt: new Date()

_demo/server/api/todos/stats.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { sql } from 'drizzle-orm'
22

33
export default eventHandler(async () => {
44
// Count the total number of todos
5-
return await useDatabase().select({
5+
return await useDB().select({
66
todos: sql<number>`count(*)`,
77
users: sql<number>`count(distinct(${tables.todos.userId}))`
88
}).from(tables.todos).get()

_demo/server/plugins/migrations.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
export default defineNitroPlugin(() => {
22
if (import.meta.dev) {
33
onHubReady(async () => {
4-
const db = useDatabase()
4+
const db = useDB()
5+
56
await db.run(sql`CREATE TABLE IF NOT EXISTS todos (
67
id integer PRIMARY KEY NOT NULL,
78
user_id integer NOT NULL,

0 commit comments

Comments
 (0)