Skip to content

Commit 82b611e

Browse files
committed
chore: wip
1 parent fd7c301 commit 82b611e

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed
Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
import process from 'node:process'
21
import { searchEngine } from '@stacksjs/config'
32
import { log } from '@stacksjs/logging'
3+
import type { MeiliSearchOptions, SearchEngineDriver } from '@stacksjs/types'
4+
import { ExitCode } from '@stacksjs/types'
5+
import type { SearchResponse } from 'meilisearch'
46
import { MeiliSearch } from 'meilisearch'
7+
import process from 'node:process'
58

6-
import type { SearchResponse } from 'meilisearch' // TODO: import from @stacksjs/types
7-
8-
interface SearchEngineOptions {
9-
host: string
10-
apiKey: string
11-
}
12-
13-
function client(options?: SearchEngineOptions) {
9+
function client(options?: MeiliSearchOptions) {
1410
let host = searchEngine.meilisearch?.host
1511
let apiKey = searchEngine.meilisearch?.apiKey
1612

@@ -22,7 +18,7 @@ function client(options?: SearchEngineOptions) {
2218

2319
if (!host) {
2420
log.error('Please specify a search engine host.')
25-
process.exit()
21+
process.exit(ExitCode.FatalError)
2622
}
2723

2824
return new MeiliSearch({ host, apiKey })
@@ -34,7 +30,8 @@ async function search(index: string, params: any): Promise<SearchResponse<Record
3430
.search(params.query, { limit: params.perPage, offset: params.page * params.perPage })
3531
}
3632

37-
export {
33+
export default {
3834
client,
3935
search,
40-
}
36+
// ...other methods
37+
} satisfies SearchEngineDriver

0 commit comments

Comments
 (0)