File tree Expand file tree Collapse file tree 1 file changed +26
-13
lines changed Expand file tree Collapse file tree 1 file changed +26
-13
lines changed Original file line number Diff line number Diff line change @@ -46,19 +46,32 @@ async function getKey(permission: string): Promise<string> {
46
46
}
47
47
48
48
async function getClient ( permission : string ) : Promise < MeiliSearch > {
49
- const apiKey =
50
- permission === 'Search' || permission === 'Admin'
51
- ? await getKey ( permission )
52
- : permission === 'No'
53
- ? undefined
54
- : null ;
55
-
56
- return apiKey === null
57
- ? masterClient
58
- : new MeiliSearch ( {
59
- host : HOST ,
60
- apiKey,
61
- } ) ;
49
+ if ( permission === 'No' ) {
50
+ const anonymousClient = new MeiliSearch ( {
51
+ host : HOST ,
52
+ } ) ;
53
+ return anonymousClient ;
54
+ }
55
+
56
+ if ( permission === 'Search' ) {
57
+ const searchKey = await getKey ( permission ) ;
58
+ const searchClient = new MeiliSearch ( {
59
+ host : HOST ,
60
+ apiKey : searchKey ,
61
+ } ) ;
62
+ return searchClient ;
63
+ }
64
+
65
+ if ( permission === 'Admin' ) {
66
+ const adminKey = await getKey ( permission ) ;
67
+ const adminClient = new MeiliSearch ( {
68
+ host : HOST ,
69
+ apiKey : adminKey ,
70
+ } ) ;
71
+ return adminClient ;
72
+ }
73
+
74
+ return masterClient ;
62
75
}
63
76
64
77
const clearAllIndexes = async ( config : Config ) : Promise < void > => {
You can’t perform that action at this time.
0 commit comments