buster/web/.cursor/rules/api_buster_socket_rules.mdc

79 lines
2.5 KiB
Plaintext

---
description: Rules for how the buster_socket api directory shoudl function
globs: src/api/buster_socket/**/*
---
# API Structure Rules
## Directory Structure
Each API namespace should follow this specific structure:
```
src/api/{namespace}/
├── {namespace}Requests.ts # Contains all request interfaces and types
├── {namespace}Responses.ts # Contains all response interfaces and types
└── index.ts # Exports all public interfaces and functions
```
## File Requirements
### {namespace}Requests.ts
- Must contain all request interfaces and types for the namespace
- Each request interface should be prefixed with the namespace
- Example: `interface UserCreateRequest { ... }`
- Must include proper TypeScript types and documentation
### {namespace}Responses.ts
- Must contain all response interfaces and types for the namespace
- Each response interface should be prefixed with the namespace
- Example: `interface UserCreateResponse { ... }`
- Must include proper TypeScript types and documentation
### index.ts
- Must export all public interfaces, types, and functions
- Should re-export from both requests and responses files
- Should contain any namespace-specific utility functions
- Must use named exports (no default exports)
## Naming Conventions
- All file names must use PascalCase for namespace names
- All interface names must be prefixed with the namespace
- All type names must be prefixed with the namespace
- Use descriptive names that clearly indicate purpose
## Documentation Requirements
- Each interface must have JSDoc comments explaining its purpose
- Each property in interfaces must be documented
- Include examples where appropriate
- Document any validation requirements or constraints
## Type Safety
- Avoid using `any` type. We should NEVER use any types.
- Use strict TypeScript configurations
- Define proper type guards when necessary
- Use generics appropriately for reusable types
## Example Structure
```typescript
// {namespace}Requests.ts
export interface {Namespace}CreateRequest {
// properties
}
// {namespace}Responses.ts
export interface {Namespace}CreateResponse {
// properties
}
// index.ts
export * from './{namespace}Requests';
export * from './{namespace}Responses';
```
## Additional Guidelines
1. Keep files focused and single-responsibility
2. Use TypeScript's strict mode
3. Implement proper error handling types
4. Follow consistent formatting
5. Include proper type exports
6. Maintain backward compatibility
7. Use enums for fixed sets of values