Cursor rule
.cursor/rules/api-patterns.mdcCursor rules
Quality
58/100
Scores the file, not the repository.Length
462 words
12 headings · 1 code blocksRepository
0
— · pushed 0 days agoLast changed
3 days ago
First indexed 3 days ago.1# API Patterns and Data Management23## Supabase Integration45- Use `src/lib/supabase.ts` for all Supabase operations6- Access Supabase client via `supabase` export7- Use environment variables for configuration8- Handle authentication state through `AuthContext`910## Service Layer Pattern1112- Create service files in `src/lib/` for business logic13- Use descriptive names: `orderService.ts`, `paymentService.ts`14- Export functions, not classes15- Handle errors consistently across services1617## API Response Handling1819- Always handle success and error cases20- Use proper TypeScript types for API responses21- Implement proper error boundaries and user feedback22- Use toast notifications for user feedback (via sonner)2324## Pagination Implementation2526- Always implement pagination for list APIs27- Use `count` and `skip` parameters for Supabase queries28- Show fewer items per page initially (10-20 items)29- Provide pagination controls at the bottom30- Allow users to navigate between pages3132## Data Fetching Patterns3334- Use React Query or SWR for server state management35- Implement proper loading states with skeletons36- Handle empty states gracefully37- Cache data appropriately to reduce API calls3839## Error Handling4041- Define custom error types in `src/types/`42- Use try-catch blocks for async operations43- Provide meaningful error messages to users44- Log errors for debugging (use `Logger` component)4546## Authentication Flow4748- Use Supabase Auth for user management49- Handle social login (Google, etc.)50- Implement proper route protection51- Use `PublicRoute` and `ProtectedRoute` components5253## File Upload5455- Use Supabase Storage for file uploads56- Implement image compression before upload57- Handle upload progress and errors58- Validate file types and sizes5960## Payment Integration6162- Use Razorpay for payment processing63- Implement proper payment flow with error handling64- Store payment status in database65- Handle webhook notifications6667## Example Patterns6869```typescript70// Good: Service function pattern71export const fetchProducts = async (page: number = 1, limit: number = 10) => {72 try {73 const { data, error, count } = await supabase74 .from("products")75 .select("*", { count: "exact" })76 .range((page - 1) * limit, page * limit - 1)77 .eq("status", LISTING_STATUS.APPROVED);7879 if (error) throw error;8081 return { data, count, page, limit };82 } catch (error) {83 console.error("Error fetching products:", error);84 throw new Error("Failed to fetch products");85 }86};8788// Good: API call with proper error handling89const handleSubmit = async (formData: FormData) => {90 try {91 setIsLoading(true);92 const result = await createOrder(formData);93 toast.success("Order created successfully!");94 navigate("/orders");95 } catch (error) {96 toast.error("Failed to create order. Please try again.");97 console.error("Order creation error:", error);98 } finally {99 setIsLoading(false);100 }101};102```103104## Database Schema105106- Use consistent naming conventions (snake_case for DB, camelCase for JS)107- Implement proper RLS (Row Level Security) policies108- Use appropriate data types and constraints109- Create indexes for frequently queried fields110 description:111 globs:112 alwaysApply: false113114---115
Also in KAMAL20201/SneakerMarketplace
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| KAMAL20201/SneakerMarketplace.cursor/rules/development-workflow.mdc · 0 | Cursor rules | buildteststyletypes+4 | 81/100 | 3 days ago | |
| KAMAL20201/SneakerMarketplace.cursor/rules/project-conventions.mdc · 0 | Cursor rules | buildteststylearch+4 | 77/100 | 3 days ago | |
| KAMAL20201/SneakerMarketplace.cursor/rules/project-overview.mdc · 0 | Cursor rules | stylearchtypes | 52/100 | 3 days ago | |
| KAMAL20201/SneakerMarketplace.cursor/rules/react-patterns.mdc · 0 | Cursor rules | stylearchuiperformance | 58/100 | 3 days ago | |
| KAMAL20201/SneakerMarketplace.cursor/rules/typescript-standards.mdc · 0 | Cursor rules | styletypesapiui+1 | 61/100 | 3 days ago | |
| KAMAL20201/SneakerMarketplace.cursor/rules/ui-components.mdc · 0 | Cursor rules | archui | 54/100 | 3 days ago | |
| KAMAL20201/SneakerMarketplaceAGENTS.md · 0 | AGENTS.md | stylesecuritydo-not | 45/100 | 3 days ago |
Diff against .cursor/rules/development-workflow.mdc Diff against .cursor/rules/project-conventions.mdc Diff against .cursor/rules/project-overview.mdc Diff against .cursor/rules/react-patterns.mdc Diff against .cursor/rules/typescript-standards.mdc Diff against .cursor/rules/ui-components.mdc Diff against AGENTS.md
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 3 days ago |
