Skip to content

Commit 178d95c

Browse files
committed
fix: better handle remote storage for utils
1 parent ab7e216 commit 178d95c

File tree

6 files changed

+10
-7
lines changed

6 files changed

+10
-7
lines changed

src/server/api/_hub/database/[command].post.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@ export default eventHandler(async (event) => {
2727
const { query, params, colName } = await readValidatedBody(event, z.object({
2828
query: z.string().min(1).max(1e6).trim(),
2929
params: z.any().array(),
30-
colName: z.string()
30+
colName: z.string().optional()
3131
}).parse)
32-
return db.prepare(query).bind(...params).first(colName)
32+
if (colName) {
33+
return db.prepare(query).bind(...params).first(colName)
34+
}
35+
return db.prepare(query).bind(...params).first()
3336
}
3437

3538
if (command === 'batch') {

src/server/utils/analytics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function _useDataset() {
2323

2424
export function hubAnalytics() {
2525
const hub = useRuntimeConfig().hub
26-
if (import.meta.dev && hub.projectUrl) {
26+
if (import.meta.dev && hub.remote && hub.projectUrl) {
2727
return proxyHubAnalytics(hub.projectUrl, hub.projectSecretKey || hub.userToken)
2828
}
2929
const dataset = _useDataset()

src/server/utils/blob.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function _useBucket() {
5454

5555
export function hubBlob() {
5656
const hub = useRuntimeConfig().hub
57-
if (import.meta.dev && hub.projectUrl) {
57+
if (import.meta.dev && hub.remote && hub.projectUrl) {
5858
return proxyHubBlob(hub.projectUrl, hub.projectSecretKey || hub.userToken)
5959
}
6060
const bucket = _useBucket()

src/server/utils/database.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function hubDatabase(): D1Database {
1212
return _db
1313
}
1414
const hub = useRuntimeConfig().hub
15-
if (import.meta.dev && hub.projectUrl) {
15+
if (import.meta.dev && hub.remote && hub.projectUrl) {
1616
_db = proxyHubDatabase(hub.projectUrl, hub.projectSecretKey || hub.userToken)
1717
return _db
1818
}

src/server/utils/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const hubHooks = createHooks<HubHooks>()
99

1010
export function onHubReady (cb: HubHooks['bindings:ready']) {
1111
const hub = useRuntimeConfig().hub
12-
if (import.meta.dev && !hub.projectUrl) {
12+
if (import.meta.dev && !hub.remote) {
1313
return hubHooks.hookOnce('bindings:ready', cb)
1414
}
1515
cb()

src/server/utils/kv.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function hubKV(): HubKV {
2121
return _kv
2222
}
2323
const hub = useRuntimeConfig().hub
24-
if (import.meta.dev && hub.projectUrl) {
24+
if (import.meta.dev && hub.remote && hub.projectUrl) {
2525
return proxyHubKV(hub.projectUrl, hub.projectSecretKey || hub.userToken)
2626
}
2727
// @ts-ignore

0 commit comments

Comments
 (0)