2023-09-28 10:01:04 +00:00
|
|
|
import { router, workspaceProcedure } from '../trpc';
|
|
|
|
import { z } from 'zod';
|
|
|
|
import { getWebsiteOnlineUserCount } from '../../model/website';
|
2023-10-06 07:04:55 +00:00
|
|
|
import { prisma } from '../../model/_client';
|
2023-09-28 10:01:04 +00:00
|
|
|
|
|
|
|
export const websiteRouter = router({
|
|
|
|
onlineCount: workspaceProcedure
|
|
|
|
.input(
|
|
|
|
z.object({
|
|
|
|
websiteId: z.string(),
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.query(async ({ input }) => {
|
|
|
|
const websiteId = input.websiteId;
|
|
|
|
|
|
|
|
const count = await getWebsiteOnlineUserCount(websiteId);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}),
|
2023-10-06 07:04:55 +00:00
|
|
|
info: workspaceProcedure
|
|
|
|
.input(
|
|
|
|
z.object({
|
|
|
|
websiteId: z.string(),
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.query(async ({ input }) => {
|
|
|
|
const { websiteId, workspaceId } = input;
|
|
|
|
|
|
|
|
const website = await prisma.website.findUnique({
|
|
|
|
where: {
|
|
|
|
id: websiteId,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
return website;
|
|
|
|
}),
|
2023-09-28 10:01:04 +00:00
|
|
|
});
|