MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / createAccountKeyAndPersist

Function createAccountKeyAndPersist

packages/typesense/src/utils/shared.ts:194–223  ·  view source on GitHub ↗
({
  account,
}: {
  account: accounts;
})

Source from the content-addressed store, hash-verified

192}
193
194export async function createAccountKeyAndPersist({
195 account,
196}: {
197 account: accounts;
198}) {
199 const isPublic = account.type === 'PUBLIC';
200
201 const key = isPublic
202 ? createAccountKey({
203 keyWithSearchPermissions: env.TYPESENSE_SEARCH_ONLY,
204 accountId: account.id,
205 })
206 : undefined;
207
208 const settings: SerializedSearchSettings = {
209 engine: 'typesense',
210 scope: isPublic ? 'public' : 'private',
211 apiKey: key?.value || 'private',
212 apiKeyExpiresAt: key?.expires_at,
213 };
214
215 await prisma.accounts.update({
216 where: {
217 id: account.id,
218 },
219 data: {
220 searchSettings: JSON.stringify(settings),
221 },
222 });
223}

Callers 2

refreshApiKeysFunction · 0.90

Calls 2

createAccountKeyFunction · 0.90
updateMethod · 0.45

Tested by

no test coverage detected