(collectionName: string)
| 80 | } |
| 81 | |
| 82 | export async function createSearchOnlyKey(collectionName: string) { |
| 83 | const key = await client.keys().create({ |
| 84 | description: `Search-only`, |
| 85 | actions: ['documents:search'], |
| 86 | collections: [collectionName], |
| 87 | }); |
| 88 | |
| 89 | if (!key.value || !key.expires_at) { |
| 90 | throw new Error('failed to create api key'); |
| 91 | } |
| 92 | return key; |
| 93 | } |