25 lines
527 B
TypeScript
25 lines
527 B
TypeScript
import Typesense from 'typesense'
|
|
|
|
export default defineNuxtPlugin({
|
|
name: 'typesense-client',
|
|
setup() {
|
|
const config = useRuntimeConfig()
|
|
const nodes = JSON.parse(config.public.typeSenseNodes as string)
|
|
const apiKey = config.public.typeSenseApiKey as string
|
|
|
|
const client = new Typesense.Client({
|
|
nodes,
|
|
apiKey,
|
|
numRetries: 3,
|
|
retryIntervalSeconds: 0.5,
|
|
healthcheckIntervalSeconds: 30
|
|
})
|
|
|
|
return {
|
|
provide: {
|
|
typesenseClient: client
|
|
}
|
|
}
|
|
}
|
|
})
|