tianji/src/server/trpc/routers/website.ts

38 lines
846 B
TypeScript
Raw Normal View History

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
});