File tree 2 files changed +3
-7
lines changed
playground/server/api/vectorize
src/runtime/vectorize/server/utils
2 files changed +3
-7
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,5 @@ export default eventHandler(async (event) => {
2
2
const { query } = await getValidatedQuery ( event , z . object ( {
3
3
query : z . array ( z . number ( ) )
4
4
} ) . parse )
5
- const index = hubVectorize ( 'example' )
6
- return index . query ( query )
5
+ return hubVectorize ( 'example' ) ?. query ( query ) || [ ]
7
6
} )
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ type VectorizeIndexes = keyof RuntimeConfig['hub']['vectorize'] & string
30
30
*
31
31
* @see https://hub.nuxt.com/docs/features/vectorize
32
32
*/
33
- export function hubVectorize ( index : VectorizeIndexes ) : Vectorize {
33
+ export function hubVectorize ( index : VectorizeIndexes ) : Vectorize | undefined {
34
34
requireNuxtHubFeature ( 'vectorize' )
35
35
36
36
if ( _vectorize [ index ] ) {
@@ -52,10 +52,7 @@ export function hubVectorize(index: VectorizeIndexes): Vectorize {
52
52
return _vectorize [ index ]
53
53
}
54
54
if ( import . meta. dev && ! hub . remote ) {
55
- throw createError ( {
56
- statusCode : 500 ,
57
- message : 'hubVectorize() is only supported with remote storage in development mode'
58
- } )
55
+ return undefined
59
56
}
60
57
61
58
throw createError ( `Missing Cloudflare Vectorize binding (${ bindingName } )` )
You can’t perform that action at this time.
0 commit comments