You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add comprehensive documentation for UI Design System, GitHub Integration, MCP Catalog, and user roles
- Introduced a new UI Design System guide detailing design principles, component patterns, and accessibility guidelines.
- Created a GitHub Application Integration document explaining the process of integrating GitHub with DeployStack for MCP server creation.
- Added a GitHub Integration guide outlining synchronization, OAuth configuration, and repository management features.
- Developed an MCP Server Catalog documentation to facilitate server discovery, management, and deployment processes.
- Updated roles documentation to include specific permissions related to the MCP Catalog and server management capabilities.
- Enhanced team documentation to clarify MCP server settings and GitHub integration for team-specific deployments.
Copy file name to clipboardExpand all lines: docs/deploystack/development/backend/api.mdx
+130-1Lines changed: 130 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,17 @@ The DeployStack Backend uses Fastify with Swagger plugins to automatically gener
15
15
-**Postman Integration**: JSON/YAML specs that can be imported into Postman
16
16
-**Automated Generation**: Specifications are generated from actual route code
17
17
18
+
## 🔒 Security First
19
+
20
+
**IMPORTANT**: Before developing any protected API endpoints, read the [API Security Best Practices](./api-security.mdx) documentation. It covers critical security patterns including:
21
+
22
+
-**Authorization Before Validation**: Why `preValidation` must be used instead of `preHandler` for authorization
23
+
-**Proper Error Responses**: Ensuring unauthorized users get 403 Forbidden, not validation errors
24
+
-**Security Testing**: How to test authorization properly
25
+
-**Common Pitfalls**: Security anti-patterns to avoid
26
+
27
+
**Key Rule**: Always use `preValidation` for authorization checks to prevent information disclosure to unauthorized users.
28
+
18
29
## Available Commands
19
30
20
31
### 1. Generate Complete API Specification
@@ -99,6 +110,8 @@ When the server is running (`npm run dev`), you can access:
99
110
2.**Directory Organization**: Group related routes in directories (e.g., `/auth/`, `/users/`, `/health/`)
100
111
3.**Import Pattern**: Routes are imported and registered in `src/routes/index.ts`
101
112
4.**Consistent Naming**: Use descriptive names that match the route purpose
113
+
5.**Modular Approach**: **Keep route files small and focused** - aim for 1-3 related methods per file maximum
114
+
6.**Maintainability**: Avoid large monolithic route files that become difficult to maintain
102
115
103
116
### Correct File Structure
104
117
@@ -120,6 +133,37 @@ services/backend/src/routes/
120
133
└── index.ts # Team management endpoints
121
134
```
122
135
136
+
### Modular Route Organization (Recommended)
137
+
138
+
For complex feature areas, break down routes into smaller, focused files:
139
+
140
+
```
141
+
services/backend/src/routes/mcp/
142
+
├── index.ts # Route registration only
143
+
├── categories/
144
+
│ ├── create.ts # POST /api/mcp/categories (1 method)
145
+
│ ├── update.ts # PUT /api/mcp/categories/{id} (1 method)
To add OpenAPI documentation to your routes, define your request body and response schemas using Zod. Then, use the `zodToJsonSchema` utility to convert these Zod schemas into the JSON Schema format expected by Fastify.
description: 'Detailed description of what this endpoint does, its parameters, and expected outcomes.',
358
+
description: 'Detailed description of what this endpoint does, its parameters, and expected outcomes. Requires Content-Type: application/json header when sending request body.',
250
359
security: [{ cookieAuth: [] }], // Include if authentication is required
251
360
body: zodToJsonSchema(myRequestBodySchema, {
252
361
$refStrategy: 'none', // Keeps definitions inline, often simpler for Fastify
253
362
target: 'openApi3'// Ensures compatibility with OpenAPI 3.0
5.**Type Safety**: Handlers receive properly typed, validated data
302
422
6.**Cleaner Code**: No redundant validation logic in handlers
303
423
424
+
### Why Both `body` and `requestBody` Properties?
425
+
426
+
**Important**: You need BOTH properties for complete functionality:
427
+
428
+
-**`body`**: Enables Fastify's automatic request validation using the Zod schema
429
+
-**`requestBody`**: Ensures proper OpenAPI specification generation with Content-Type documentation
430
+
431
+
Without `body`, validation won't work. Without `requestBody`, your API specification won't properly document the `application/json` Content-Type requirement.
0 commit comments