( serviceId: string, serviceType: ServiceType, )
| 32 | import { createTRPCRouter, protectedProcedure } from "../trpc"; |
| 33 | |
| 34 | async function getServiceOrganizationId( |
| 35 | serviceId: string, |
| 36 | serviceType: ServiceType, |
| 37 | ): Promise<string | null> { |
| 38 | switch (serviceType) { |
| 39 | case "application": { |
| 40 | const app = await findApplicationById(serviceId); |
| 41 | return app?.environment?.project?.organizationId ?? null; |
| 42 | } |
| 43 | case "postgres": { |
| 44 | const postgres = await findPostgresById(serviceId); |
| 45 | return postgres?.environment?.project?.organizationId ?? null; |
| 46 | } |
| 47 | case "mariadb": { |
| 48 | const mariadb = await findMariadbById(serviceId); |
| 49 | return mariadb?.environment?.project?.organizationId ?? null; |
| 50 | } |
| 51 | case "mongo": { |
| 52 | const mongo = await findMongoById(serviceId); |
| 53 | return mongo?.environment?.project?.organizationId ?? null; |
| 54 | } |
| 55 | case "mysql": { |
| 56 | const mysql = await findMySqlById(serviceId); |
| 57 | return mysql?.environment?.project?.organizationId ?? null; |
| 58 | } |
| 59 | case "redis": { |
| 60 | const redis = await findRedisById(serviceId); |
| 61 | return redis?.environment?.project?.organizationId ?? null; |
| 62 | } |
| 63 | case "compose": { |
| 64 | const compose = await findComposeById(serviceId); |
| 65 | return compose?.environment?.project?.organizationId ?? null; |
| 66 | } |
| 67 | case "libsql": { |
| 68 | const libsql = await findLibsqlById(serviceId); |
| 69 | return libsql?.environment?.project?.organizationId ?? null; |
| 70 | } |
| 71 | default: |
| 72 | return null; |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | export const mountRouter = createTRPCRouter({ |
| 77 | create: protectedProcedure |
no test coverage detected