From 4f5e79157aea86e0095fc8e947767f6d521d889f Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Thu, 4 Jan 2024 00:34:33 +0800 Subject: [PATCH] style: remove unused code --- src/client/api/model/website.ts | 35 --------------------------- src/server/router/workspace.ts | 42 --------------------------------- 2 files changed, 77 deletions(-) diff --git a/src/client/api/model/website.ts b/src/client/api/model/website.ts index a498e48..fa11afa 100644 --- a/src/client/api/model/website.ts +++ b/src/client/api/model/website.ts @@ -7,18 +7,6 @@ import { AppRouterOutput } from '../trpc'; export type WebsiteInfo = NonNullable; -export async function getWorkspaceWebsites( - workspaceId: string -): Promise { - const { data } = await request.get('/api/workspace/websites', { - params: { - workspaceId, - }, - }); - - return data.websites; -} - export async function deleteWorkspaceWebsite( workspaceId: string, websiteId: string @@ -28,33 +16,10 @@ export async function deleteWorkspaceWebsite( queryClient.resetQueries(['websites', workspaceId]); } -export function useWorspaceWebsites(workspaceId: string) { - const { data: websites = [], isLoading } = useQuery( - ['websites', workspaceId], - () => { - return getWorkspaceWebsites(workspaceId); - } - ); - - return { websites, isLoading }; -} - export function refreshWorkspaceWebsites(workspaceId: string) { queryClient.refetchQueries(['websites', workspaceId]); } -export async function addWorkspaceWebsite( - workspaceId: string, - name: string, - domain: string -) { - await request.post('/api/workspace/website', { - workspaceId, - name, - domain, - }); -} - export async function getWorkspaceWebsitePageview( workspaceId: string, websiteId: string, diff --git a/src/server/router/workspace.ts b/src/server/router/workspace.ts index 10373c9..47d4a72 100644 --- a/src/server/router/workspace.ts +++ b/src/server/router/workspace.ts @@ -17,48 +17,6 @@ import { ROLES } from '../../shared'; export const workspaceRouter = Router(); -workspaceRouter.get( - '/websites', - validate( - query('workspaceId').isString().withMessage('workspaceId should be string') - ), - auth(), - workspacePermission(), - async (req, res) => { - const workspaceId = req.query.workspaceId as string; - - const websites = await getWorkspaceWebsites(workspaceId); - - res.json({ websites }); - } -); - -workspaceRouter.post( - '/website', - validate( - body('workspaceId').isString(), - body('name') - .isString() - .withMessage('name should be string') - .isLength({ max: 100 }) - .withMessage('length should be under 100'), - body('domain') - .isURL() - .withMessage('domain should be URL') - .isLength({ max: 500 }) - .withMessage('length should be under 500') - ), - auth(), - workspacePermission(), - async (req, res) => { - const { workspaceId, name, domain } = req.body; - - const website = await addWorkspaceWebsite(workspaceId, name, domain); - - res.json({ website }); - } -); - workspaceRouter.delete( '/:workspaceId/website/:websiteId', validate(param('workspaceId').isString(), param('websiteId').isString()),