(userId: string)
| 2 | import { generateApiKey } from "./generateApiKey"; |
| 3 | |
| 4 | export default async function userProject(userId: string) { |
| 5 | return await prisma.project.upsert({ |
| 6 | where: { |
| 7 | personalProjectUserId: userId, |
| 8 | }, |
| 9 | update: {}, |
| 10 | create: { |
| 11 | personalProjectUserId: userId, |
| 12 | projectUsers: { |
| 13 | create: { |
| 14 | userId: userId, |
| 15 | role: "OWNER", |
| 16 | }, |
| 17 | }, |
| 18 | apiKeys: { |
| 19 | create: [ |
| 20 | { |
| 21 | name: "Default API Key", |
| 22 | apiKey: generateApiKey(), |
| 23 | }, |
| 24 | { |
| 25 | name: "Read-Only API Key", |
| 26 | apiKey: generateApiKey(), |
| 27 | readOnly: true, |
| 28 | }, |
| 29 | ], |
| 30 | }, |
| 31 | }, |
| 32 | }); |
| 33 | } |
no test coverage detected