@meeovi/search 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +1 -0
- package/package.json +20 -0
- package/src/config.ts +20 -0
- package/src/useSearch.ts +16 -0
package/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/useSearch'
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@meeovi/search",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@searchkit/client": "^3.0.0",
|
|
11
|
+
"@searchkit/instantsearch-client": "latest",
|
|
12
|
+
"searchkit": "latest",
|
|
13
|
+
"vue": "^3.2.47",
|
|
14
|
+
"vue-instantsearch": "4.4.2"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [],
|
|
17
|
+
"author": "",
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"type": "commonjs"
|
|
20
|
+
}
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
export interface SearchConfig {
|
|
3
|
+
searchProvider: string
|
|
4
|
+
searchUrl?: string
|
|
5
|
+
apiKey?: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
let config: SearchConfig = {
|
|
9
|
+
searchProvider: 'searchkit',
|
|
10
|
+
searchUrl: '',
|
|
11
|
+
apiKey: ''
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function setSearchConfig(newConfig: Partial<SearchConfig>) {
|
|
15
|
+
config = { ...config, ...newConfig }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function getSearchConfig(): SearchConfig {
|
|
19
|
+
return config
|
|
20
|
+
}
|
package/src/useSearch.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SearchkitClient } from '@searchkit/client'
|
|
2
|
+
import { useRuntimeConfig } from '#imports'
|
|
3
|
+
|
|
4
|
+
let client: any = null
|
|
5
|
+
|
|
6
|
+
export function useSearch() {
|
|
7
|
+
if (!client) {
|
|
8
|
+
const config = useRuntimeConfig()
|
|
9
|
+
client = new SearchkitClient({ url: config.public.searchUrl })
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
query: client.query.bind(client),
|
|
14
|
+
fetch: client.fetch.bind(client)
|
|
15
|
+
}
|
|
16
|
+
}
|