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

Function createUserKeyAndPersist

packages/typesense/src/utils/shared.ts:164–192  ·  view source on GitHub ↗
({
  account,
  user,
  isPublic,
}: {
  account: accounts;
  user: users;
  isPublic: boolean;
})

Source from the content-addressed store, hash-verified

162}
163
164export async function createUserKeyAndPersist({
165 account,
166 user,
167 isPublic,
168}: {
169 account: accounts;
170 user: users;
171 isPublic: boolean;
172}) {
173 const key = createUserKey({
174 keyWithSearchPermissions: env.TYPESENSE_SEARCH_ONLY,
175 accountId: account.id,
176 userId: user.id,
177 });
178 const settings: SerializedSearchSettings = {
179 apiKey: key.value,
180 apiKeyExpiresAt: key.expires_at,
181 engine: 'typesense',
182 scope: isPublic ? 'public' : 'private',
183 };
184 await prisma.users.update({
185 where: {
186 id: user.id,
187 },
188 data: {
189 searchSettings: JSON.stringify(settings),
190 },
191 });
192}
193
194export async function createAccountKeyAndPersist({
195 account,

Callers 2

refreshApiKeysFunction · 0.90
setupFunction · 0.90

Calls 2

createUserKeyFunction · 0.90
updateMethod · 0.45

Tested by

no test coverage detected