Skip to content

Commit b98d943

Browse files
committed
chore: setup nuxthub v1 database
1 parent ecb8cf8 commit b98d943

34 files changed

+126
-121
lines changed

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ docs/
2626
!.env.example
2727

2828
# Database import data (contains API responses)
29-
database/data/
30-
database/sql/*.sql
31-
!database/sql/1.rls-policies.sql
32-
!database/sql/2.category-hierarchies.sql
29+
server/database/data/
30+
server/database/sql/*.sql
31+
!server/database/sql/1.rls-policies.sql
32+
!server/database/sql/2.category-hierarchies.sql
3333

3434
.pnpm-store
3535

drizzle.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import process from 'node:process'
22
import { defineConfig } from 'drizzle-kit'
33

4+
// TODO Maybe remove this file when NuxtHub v1 is stable
5+
46
export default defineConfig({
57
dialect: 'postgresql',
6-
schema: './database/schema.ts',
7-
out: './database/migrations',
8+
schema: './server/database/schema.ts',
9+
out: './server/database/migrations',
810
dbCredentials: {
911
url: process.env.DATABASE_URL!,
1012
},

nuxt.config.ts

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,9 @@ import { icons as nimiqFlags } from 'nimiq-flags'
33
import { icons as nimiqIcons } from 'nimiq-icons'
44
import { defineNuxtConfig } from 'nuxt/config'
55
import * as v from 'valibot'
6+
import { scheduler } from 'node:timers/promises'
67

78
export default defineNuxtConfig({
8-
hooks: {
9-
'pages:extend': (pages) => {
10-
// Only run this logic if we are in production
11-
if (process.env.NODE_ENV === 'production') {
12-
// Remove any page that starts with 'dev-' or is in a 'dev' folder
13-
const pagesToRemove = pages.filter((page) => {
14-
return page.path.includes('/dev') || page.name?.startsWith('dev-')
15-
})
16-
17-
pagesToRemove.forEach((page) => {
18-
const index = pages.indexOf(page)
19-
if (index > -1) {
20-
pages.splice(index, 1)
21-
}
22-
})
23-
}
24-
},
25-
},
269
modules: [
2710
'@nuxthub/core-nightly',
2811
'@unocss/nuxt',
@@ -43,7 +26,10 @@ export default defineNuxtConfig({
4326
hub: {
4427
blob: true,
4528
kv: true,
46-
database: 'postgresql',
29+
database: {
30+
dialect: 'postgresql',
31+
32+
},
4733
},
4834
eslint: {
4935
config: {
@@ -53,6 +39,7 @@ export default defineNuxtConfig({
5339
runtimeConfig: {
5440
googleApiKey: process.env.GOOGLE_API_KEY || '',
5541
openaiApiKey: process.env.OPENAI_API_KEY || '',
42+
databaseUrl: process.env.DATABASE_URL || '',
5643
public: {
5744
siteURL: import.meta.dev
5845
? ' http://localhost:3000'
@@ -63,6 +50,7 @@ export default defineNuxtConfig({
6350
$schema: v.object({
6451
googleApiKey: v.pipe(v.string(), v.minLength(1, 'GOOGLE_API_KEY is required')),
6552
openaiApiKey: v.pipe(v.string(), v.minLength(1, 'OPENAI_API_KEY is required')),
53+
databaseUrl: v.pipe(v.string(), v.minLength(1, 'DATABASE_URL is required')),
6654
public: v.object({ siteURL: v.string() }),
6755
}),
6856
},

package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
"prepare": "nuxt prepare",
1313
"postinstall": "nuxt prepare",
1414
"db:generate": "drizzle-kit generate",
15-
"db:generate-category-embeddings": "tsx database/scripts/generate-category-embeddings.ts",
16-
"db:generate-functions": "tsx database/scripts/generate-function-types.ts",
17-
"db:enrich-ratings": "tsx database/scripts/enrich-with-ratings.ts",
18-
"db:clean-locations": "tsx database/scripts/clean-locations.ts",
19-
"db:prepare-data": "tsx database/scripts/prepare-data.ts",
20-
"db:apply-naka": "tsx database/scripts/apply-naka-data.ts",
21-
"db:nuke": "tsx database/scripts/db-reset.ts",
22-
"db:setup": "tsx database/scripts/db-setup.ts && pnpm run db:generate-functions",
15+
"db:generate-category-embeddings": "tsx server/database/scripts/generate-category-embeddings.ts",
16+
"db:generate-functions": "tsx server/database/scripts/generate-function-types.ts",
17+
"db:enrich-ratings": "tsx server/database/scripts/enrich-with-ratings.ts",
18+
"db:clean-locations": "tsx server/database/scripts/clean-locations.ts",
19+
"db:prepare-data": "tsx server/database/scripts/prepare-data.ts",
20+
"db:apply-naka": "tsx server/database/scripts/apply-naka-data.ts",
21+
"db:nuke": "tsx server/database/scripts/db-reset.ts",
22+
"db:setup": "tsx server/database/scripts/db-setup.ts && pnpm run db:generate-functions",
2323
"lint": "eslint . --cache",
2424
"lint:fix": "eslint . --fix --cache",
2525
"test": "vitest run",
@@ -28,6 +28,7 @@
2828
},
2929
"dependencies": {
3030
"@ai-sdk/openai": "catalog:utils",
31+
"@electric-sql/pglite": "^0.3.14",
3132
"@nuxt/fonts": "catalog:framework",
3233
"@nuxt/icon": "catalog:framework",
3334
"@nuxt/image": "catalog:framework",

pnpm-lock.yaml

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

pnpm-workspace.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
catalog:
2-
'@vueuse/core': ^14.0.0
2+
'@vueuse/core': ^13.8.0
33
zod: ^4.1.13
4+
45
catalogs:
56
database:
67
drizzle-kit: ^0.31.7
@@ -23,8 +24,8 @@ catalogs:
2324
'@nuxt/image': ^2.0.0
2425
'@nuxthub/core-nightly': latest
2526
'@nuxtjs/i18n': ^10.2.1
26-
'@vueuse/nuxt': ^14.0.0
27-
'@vueuse/router': ^14.0.0
27+
'@vueuse/nuxt': ^13.8.0
28+
'@vueuse/router': ^13.8.0
2829
nuxt: ^4.2.1
2930
nuxt-maplibre: ^1.2.0
3031
nuxt-safe-runtime-config: ^0.0.10
@@ -55,8 +56,11 @@ catalogs:
5556
opening_hours: ^3.9.0
5657
pathe: ^2.0.3
5758
valibot: ^1.2.0
59+
5860
onlyBuiltDependencies:
5961
- '@parcel/watcher'
6062
- esbuild
6163
- sharp
64+
- unrs-resolver
65+
- vue-demi
6266
- workerd
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { Buffer } from 'node:buffer'
2+
13
/**
24
* PostgreSQL function type definitions
35
* Auto-generated from SQL files in database/functions/
File renamed without changes.
File renamed without changes.

database/migrations/meta/0000_snapshot.json renamed to server/database/migrations/meta/0000_snapshot.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id": "e1cb88a9-f631-46cc-90d8-e512fc1eb179",
2+
"id": "8cfff89d-abd8-4902-aa24-3bdfdbe1746e",
33
"prevId": "00000000-0000-0000-0000-000000000000",
44
"version": "7",
55
"dialect": "postgresql",
@@ -422,4 +422,4 @@
422422
"schemas": {},
423423
"tables": {}
424424
}
425-
}
425+
}

0 commit comments

Comments
 (0)