Skip to content

Commit 77e6800

Browse files
committed
chore: improve loggings
1 parent 5223aef commit 77e6800

File tree

5 files changed

+9
-20
lines changed

5 files changed

+9
-20
lines changed

_nuxthub/modules/hub/index.ts

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineNuxtModule, createResolver } from 'nuxt/kit'
1+
import { defineNuxtModule, createResolver, logger } from 'nuxt/kit'
22
import { join } from 'pathe'
33
import { defu } from 'defu'
44
import { mkdir, writeFile, readFile } from 'node:fs/promises'
@@ -10,20 +10,17 @@ export default defineNuxtModule({
1010
async setup (_options, nuxt) {
1111
const { resolve } = createResolver(import.meta.url)
1212

13-
// Add Server utils based on environment
14-
// nuxt.options.nitro.imports = nuxt.options.nitro.imports || {}
15-
// nuxt.options.nitro.imports.dirs = nuxt.options.nitro.imports.dirs || []
16-
// nuxt.options.nitro.imports.dirs.push(resolve(`../server/_utils/${nuxt.options.dev ? 'dev' : 'prod'}/`))
17-
1813
// Production mode
1914
if (!nuxt.options.dev) {
2015
return
2116
}
2217

2318
if (process.env.NUXT_HUB_URL) {
2419
// TODO: check on hub.nuxt.com if the project is connected
25-
// return
26-
// return once we support Proxy for all providers (R2 missing now)
20+
logger.info(`Using remote hub from \`${process.env.NUXT_HUB_URL}\``)
21+
return
22+
} else {
23+
logger.info('Using local hub from bindings')
2724
}
2825

2926
// Local development without remote connection
@@ -52,9 +49,6 @@ export default defineNuxtModule({
5249
configPath: wranglerPath,
5350
persistDir: hubDir
5451
})
55-
// Make sure runtime is transpiled
56-
// nuxt.options.nitro.externals.inline = nuxt.options.nitro.externals.inline || []
57-
// nuxt.options.nitro.externals.inline.push(resolve('./runtime/server'))
5852
// Add server plugin
5953
nuxt.options.nitro.plugins = nuxt.options.nitro.plugins || []
6054
nuxt.options.nitro.plugins.push(resolve('./runtime/server/plugins/cloudflare.dev'))
@@ -69,4 +63,4 @@ kv_namespaces = [
6963
]
7064
r2_buckets = [
7165
{ binding = "BLOB", bucket_name = "default" },
72-
]`
66+
]`

_nuxthub/server/utils/blob.ts

-3
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ export function useBlob () {
3030
const proxyURL = import.meta.dev && process.env.NUXT_HUB_URL
3131
let bucket: R2Bucket
3232
if (!proxyURL) {
33-
import.meta.dev && console.log('Using Blob local storage...')
3433
bucket = _useBucket()
35-
} else {
36-
import.meta.dev && console.log('Using Blob remote storage...')
3734
}
3835

3936
return {

_nuxthub/server/utils/database.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import { drizzle as drizzleHTTP } from 'drizzle-orm/sqlite-proxy'
55
import type { SqliteRemoteDatabase } from 'drizzle-orm/sqlite-proxy'
66
import { ofetch } from 'ofetch'
77

8+
export { sql } from 'drizzle-orm'
9+
10+
// TODO: generate #hub/database/schema from the database
811
export * as tables from '~/server/database/schema'
912

1013
let _db: DrizzleD1Database | BetterSQLite3Database | SqliteRemoteDatabase
@@ -13,7 +16,6 @@ let _client: D1Database
1316
export function useDatabase () {
1417
if (!_db) {
1518
if (import.meta.dev && process.env.NUXT_HUB_URL) {
16-
console.log('Using D1 remote database...')
1719
_db = drizzleHTTP(async (sql, params, method) => {
1820
// https://orm.drizzle.team/docs/get-started-sqlite#http-proxy
1921
try {
@@ -40,7 +42,6 @@ export function useDatabase () {
4042
if (binding) {
4143
_client = binding as D1Database
4244
_db = drizzleD1(_client)
43-
import.meta.dev && console.log('Using D1 local database...')
4445
} else {
4546
throw createError('Missing Cloudflare D1 binding DB')
4647
}

_nuxthub/server/utils/kv.ts

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ let _kv: Storage
99
export function useKV () {
1010
if (!_kv) {
1111
if (import.meta.dev && process.env.NUXT_HUB_URL) {
12-
console.log('Using KV remote namespace...')
1312
// Use https://unstorage.unjs.io/drivers/http
1413
_kv = createStorage({
1514
driver: httpDriver({

server/plugins/migrations.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { sql } from 'drizzle-orm'
2-
31
export default defineNitroPlugin(() => {
42
if (import.meta.dev) {
53
onHubReady(async () => {

0 commit comments

Comments
 (0)