@mallardbay/cursor-rules 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
description:
|
|
3
|
+
globs:
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
# Mallard Bay Backend Development Rules
|
|
7
|
+
|
|
8
|
+
## Project Structure
|
|
9
|
+
|
|
10
|
+
- `src/` - Main source code directory
|
|
11
|
+
- `gql/` - GraphQL types, models, and resolvers
|
|
12
|
+
- `helpers/` - Utility functions (e.g., algolia.helpers.ts, entity-algolia.helpers.ts)
|
|
13
|
+
- `config/` - Configuration files and environment variables
|
|
14
|
+
- `database/` - Database related code (Firestore, Algolia)
|
|
15
|
+
- `firebase/` - Firebase functions and triggers
|
|
16
|
+
- `services/` - Business logic services
|
|
17
|
+
- `middleware/` - Express middleware
|
|
18
|
+
|
|
19
|
+
## Environment Setup
|
|
20
|
+
|
|
21
|
+
- Use dotenv-vault for environment management
|
|
22
|
+
- Never commit .env files to git
|
|
23
|
+
- Use different .env files for different environments (dev, test, prod)
|
|
24
|
+
|
|
25
|
+
## Firebase Development
|
|
26
|
+
|
|
27
|
+
- Use Firestore emulator for local development
|
|
28
|
+
- Start emulator: `gcloud emulators firestore start --host-port=127.0.0.1:8080`
|
|
29
|
+
- Use Firebase Functions for serverless operations
|
|
30
|
+
- Keep Firebase functions in `src/firebase/functions/`
|
|
31
|
+
- Use proper error handling in Firebase functions, use `captureException` helper for it
|
|
32
|
+
- Follow Firebase security rules best practices
|
|
33
|
+
|
|
34
|
+
## Algolia Integration
|
|
35
|
+
|
|
36
|
+
- Configure Algolia indices using `bin/db/setup-algolia.ts`
|
|
37
|
+
- Follow Algolia index settings in `src/database/algolia/*-index-settings.ts`
|
|
38
|
+
- Use proper searchable attributes and faceting
|
|
39
|
+
- Keep Algolia indexing logic in `src/helpers/algolia.helpers.ts`
|
|
40
|
+
- Follow Algolia query character limits (ALGOLIA_MAX_QUERY_CHARACTER = 512)
|
|
41
|
+
- Use proper error handling for Algolia operations
|
|
42
|
+
|
|
43
|
+
## Testing
|
|
44
|
+
|
|
45
|
+
- Use Jest as the testing framework
|
|
46
|
+
- Place tests in `__tests__` directories
|
|
47
|
+
- Mock Algolia, and other network requests in tests
|
|
48
|
+
- Use `tests/setupTests.ts` for global test setup
|
|
49
|
+
- Use `tests/teardownTests.ts` for cleanup
|
|
50
|
+
- Use Jest coverage reporting in the CI but not locally
|
|
51
|
+
|
|
52
|
+
## Code Style
|
|
53
|
+
|
|
54
|
+
- Use TypeScript for all new code
|
|
55
|
+
- Follow ESLint rules from `@mallardbay/eslint-config-mallardbay`
|
|
56
|
+
- Follow existing codebase patterns
|
|
57
|
+
- Rely heavily on constants
|
|
58
|
+
- Copy should be in copy constants
|
|
59
|
+
|
|
60
|
+
## GraphQL
|
|
61
|
+
|
|
62
|
+
- Define gql types, resolvers and mutations in `[ENTITY].schema.ts` files
|
|
63
|
+
|
|
64
|
+
## Error Handling
|
|
65
|
+
|
|
66
|
+
- Use proper error types
|
|
67
|
+
- Log errors appropriately
|
|
68
|
+
- Handle edge cases
|
|
69
|
+
- Provide meaningful error messages
|
|
70
|
+
- Use try-catch blocks where appropriate
|
|
71
|
+
- Use Sentry for error tracking, use `captureException` helper for it
|
|
72
|
+
|
|
73
|
+
## Performance
|
|
74
|
+
|
|
75
|
+
- Optimize Firestore queries
|
|
76
|
+
- Use proper indexing (see `firebase/firestore.indexes.json`)
|
|
77
|
+
- Cache when appropriate
|
|
78
|
+
- Monitor performance
|
|
79
|
+
- Setup new queries with pagination
|
|
80
|
+
- Follow Algolia best practices for search
|
|
81
|
+
|
|
82
|
+
## Security
|
|
83
|
+
|
|
84
|
+
- Validate all input
|
|
85
|
+
- Sanitize user data
|
|
86
|
+
- Use proper authentication
|
|
87
|
+
- Follow security best practices
|
|
88
|
+
- Keep dependencies secure
|
|
89
|
+
- Use environment variables for sensitive data
|