Add spaces concept (#1776)

This commit is contained in:
Luke Vella 2025-06-15 11:48:51 +02:00 committed by GitHub
parent 92a72dde60
commit 04fcc0350f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 389 additions and 93 deletions

View file

@ -0,0 +1,38 @@
import { prisma } from "@rallly/database";
export async function listSpaces({ ownerId }: { ownerId: string }) {
const spaces = await prisma.space.findMany({
where: {
ownerId,
},
});
return spaces;
}
export async function getDefaultSpace({ ownerId }: { ownerId: string }) {
const space = await prisma.space.findFirst({
where: {
ownerId,
},
orderBy: {
createdAt: "asc",
},
});
if (!space) {
throw new Error(`Space with owner ID ${ownerId} not found`);
}
return space;
}
export async function getSpace({ id }: { id: string }) {
const space = await prisma.space.findUnique({
where: {
id,
},
});
return space;
}

View file

@ -2,8 +2,16 @@ import { z } from "zod";
export const subscriptionCheckoutMetadataSchema = z.object({
userId: z.string(),
spaceId: z.string().optional(),
});
export type SubscriptionCheckoutMetadata = z.infer<
typeof subscriptionCheckoutMetadataSchema
>;
export const subscriptionMetadataSchema = z.object({
userId: z.string(),
spaceId: z.string().optional(),
});
export type SubscriptionMetadata = z.infer<typeof subscriptionMetadataSchema>;