Skip to content

Commit 5f0f381

Browse files
author
Lasim
committed
refactor: update parameter schemas to use type-only definitions for consistency
1 parent f71892e commit 5f0f381

File tree

4 files changed

+18
-29
lines changed

4 files changed

+18
-29
lines changed

services/backend/src/routes/mcp/categories/delete.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { requirePermission } from '../../../middleware/roleMiddleware';
55
import { McpCategoriesService } from '../../../services/mcpCategoriesService';
66
import { getDb } from '../../../db';
77

8-
// Path parameter schema
9-
const deleteCategoryParamsSchema = z.object({
10-
id: z.string().min(1, 'Category ID is required')
11-
});
8+
// Path parameter schema (type-only)
9+
type DeleteCategoryParams = {
10+
id: string;
11+
};
1212

1313
// Response schemas
1414
const deleteCategoryResponseSchema = z.object({
@@ -47,7 +47,7 @@ export default async function deleteCategory(server: FastifyInstance) {
4747
}
4848
}
4949
}, async (request, reply) => {
50-
const { id } = request.params as z.infer<typeof deleteCategoryParamsSchema>;
50+
const { id } = request.params as DeleteCategoryParams;
5151

5252
request.log.info({
5353
operation: 'delete_mcp_category',

services/backend/src/routes/mcp/categories/update.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { requirePermission } from '../../../middleware/roleMiddleware';
55
import { McpCategoriesService } from '../../../services/mcpCategoriesService';
66
import { getDb } from '../../../db';
77

8-
// Path parameter schema
9-
const updateCategoryParamsSchema = z.object({
10-
id: z.string().min(1, 'Category ID is required')
11-
});
8+
// Path parameter schema (type-only)
9+
type UpdateCategoryParams = {
10+
id: string;
11+
};
1212

1313
// Request schema
1414
const updateCategoryRequestSchema = z.object({
@@ -83,7 +83,7 @@ export default async function updateCategory(server: FastifyInstance) {
8383
}
8484
}
8585
}, async (request, reply) => {
86-
const { id } = request.params as z.infer<typeof updateCategoryParamsSchema>;
86+
const { id } = request.params as UpdateCategoryParams;
8787
const updateData = request.body as z.infer<typeof updateCategoryRequestSchema>;
8888

8989
request.log.info({

services/backend/src/routes/mcp/installations/create.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { requireTeamPermission } from '../../../middleware/roleMiddleware';
55
import { McpInstallationService } from '../../../services/mcpInstallationService';
66
import { getDb } from '../../../db';
77

8-
// Request schema
9-
const createInstallationSchema = z.object({
10-
server_id: z.string().min(1, 'Server ID is required'),
11-
installation_name: z.string().min(1, 'Installation name is required').max(100, 'Installation name too long'),
12-
installation_type: z.enum(['local', 'cloud']).optional().default('local'),
13-
user_environment_variables: z.record(z.string(), z.string()).optional()
14-
});
8+
// Request schema (type-only)
9+
type CreateInstallationRequest = {
10+
server_id: string;
11+
installation_name: string;
12+
installation_type?: 'local' | 'cloud';
13+
user_environment_variables?: Record<string, string>;
14+
};
1515

1616
// Response schemas
1717
const successResponseSchema = z.object({
@@ -46,7 +46,7 @@ const errorResponseSchema = z.object({
4646
export default async function createInstallationRoute(fastify: FastifyInstance) {
4747
fastify.post<{
4848
Params: { teamId: string };
49-
Body: z.infer<typeof createInstallationSchema>;
49+
Body: CreateInstallationRequest;
5050
}>('/teams/:teamId/mcp/installations', {
5151
schema: {
5252
tags: ['MCP Installations'],

services/backend/src/routes/mcp/servers/search.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,6 @@ import { getUserRole, requirePermission } from '../../../middleware/roleMiddlewa
77
import { getDb } from '../../../db';
88

99

10-
// Query parameters schema for documentation (without transforms)
11-
const searchServersQuerySchemaDoc = z.object({
12-
q: z.string().min(1, 'Search query is required').max(255, 'Search query must be 255 characters or less'),
13-
category: z.string().optional(),
14-
language: z.string().optional(),
15-
runtime: z.string().optional(),
16-
status: z.enum(['active', 'deprecated', 'maintenance']).optional(),
17-
featured: z.enum(['true', 'false']).optional().describe('Filter by featured status'),
18-
limit: z.string().regex(/^\d+$/).optional().describe('Limit must be a number between 1 and 100'),
19-
offset: z.string().regex(/^\d+$/).optional().describe('Offset must be non-negative')
20-
});
2110

2211
// Response schema for search results
2312
const searchServersResponseSchema = z.object({

0 commit comments

Comments
 (0)