mirror of
https://github.com/sanjeed5/awesome-cursor-rules-mdc.git
synced 2026-11-30 14:52:55 +08:00
Add comprehensive MDC files for various technologies and frameworks
Generate a large set of Markdown Configuration (MDC) files covering best practices across multiple domains, including: - AI/ML libraries (PyTorch, TensorFlow, scikit-learn) - Backend frameworks (Django, FastAPI, Express, Spring Boot) - Frontend frameworks (React, Vue, Angular) - Cloud platforms (AWS, Azure, GCP) - Development tools (Docker, Kubernetes, Terraform) - State management libraries - UI component libraries - Web technologies and APIs Enhance project documentation with detailed, standardized best practice guidelines for different technologies and frameworks
This commit is contained in:
@@ -0,0 +1,319 @@
|
||||
---
|
||||
description: This rule provides comprehensive best practices for htmx development, covering code organization, security, performance, testing, and common pitfalls. It aims to guide developers in building robust, maintainable, and secure htmx applications.
|
||||
globs: **/*.html
|
||||
---
|
||||
# htmx Best Practices and Coding Standards
|
||||
|
||||
This document outlines the recommended best practices and coding standards for developing htmx applications. Adhering to these guidelines will help ensure code quality, maintainability, security, and performance.
|
||||
|
||||
## 1. Code Organization and Structure
|
||||
|
||||
### 1.1 Directory Structure Best Practices
|
||||
|
||||
While htmx doesn't enforce a specific directory structure, a well-organized project is crucial for maintainability. Consider the following structure as a starting point:
|
||||
|
||||
|
||||
project-root/
|
||||
├── assets/ # Static assets (CSS, JavaScript, images, fonts)
|
||||
│ ├── css/
|
||||
│ ├── js/
|
||||
│ ├── img/
|
||||
│ └── fonts/
|
||||
├── components/ # Reusable HTML snippets/components
|
||||
│ ├── button.html
|
||||
│ ├── form.html
|
||||
│ └── ...
|
||||
├── layouts/ # Page layouts (e.g., base.html, default.html)
|
||||
│ ├── base.html
|
||||
│ └── ...
|
||||
├── pages/ # Individual pages (e.g., index.html, about.html)
|
||||
│ ├── index.html
|
||||
│ └── ...
|
||||
├── scripts/ # Server-side scripts (Python, Node.js, etc.)
|
||||
│ ├── app.py # Example using Flask
|
||||
│ └── ...
|
||||
├── templates/ # Server-side templates (e.g., Jinja2, Django Templates)
|
||||
│ ├── ...
|
||||
├── .env # Environment variables
|
||||
├── requirements.txt # Python dependencies (if applicable)
|
||||
└── package.json # Node.js dependencies (if applicable)
|
||||
|
||||
|
||||
* **`assets/`**: Contains all static assets like CSS, JavaScript (including htmx extensions), images, and fonts. Organize further into subdirectories for each asset type.
|
||||
* **`components/`**: Stores reusable HTML snippets. These components can be included in various pages or other components to avoid code duplication.
|
||||
* **`layouts/`**: Defines the overall structure of pages. Common elements like headers, footers, and navigation are placed here, allowing pages to inherit a consistent look and feel.
|
||||
* **`pages/`**: Contains the HTML files for individual pages of your application. These pages usually include content and may use components and layouts.
|
||||
* **`scripts/`**: Holds server-side scripts responsible for handling requests, processing data, and rendering HTML responses. These scripts interact with htmx via the HTTP protocol.
|
||||
* **`templates/`**: Used in conjunction with server-side scripting, these are templates processed by the backend to generate HTML dynamically. (Only relevant if you are using a template engine on the backend).
|
||||
|
||||
### 1.2 File Naming Conventions
|
||||
|
||||
* **HTML files:** Use descriptive names in lowercase with hyphens (e.g., `product-details.html`, `user-profile.html`).
|
||||
* **CSS files:** Similar to HTML, use lowercase with hyphens (e.g., `main.css`, `style.css`, `components.css`).
|
||||
* **JavaScript files:** Use camelCase for file names (e.g., `utils.js`, `htmxConfig.js`).
|
||||
* **Component files:** Reflect the component's purpose (e.g., `product-card.html`, `search-form.html`).
|
||||
* **Image files:** Use descriptive names related to the image content (e.g., `product-image-1.jpg`, `user-avatar.png`).
|
||||
|
||||
### 1.3 Module Organization
|
||||
|
||||
For larger htmx projects, consider modularizing your JavaScript code. This promotes code reuse and maintainability. CommonJS or ES modules can be used, depending on your build setup.
|
||||
|
||||
javascript
|
||||
// utils.js
|
||||
export function formatDate(date) {
|
||||
// ...
|
||||
}
|
||||
|
||||
export function truncateText(text, limit) {
|
||||
// ...
|
||||
}
|
||||
|
||||
// main.js
|
||||
import { formatDate, truncateText } from './utils.js';
|
||||
|
||||
// ...
|
||||
|
||||
|
||||
### 1.4 Component Architecture
|
||||
|
||||
Break down your user interface into reusable components. This makes your code easier to understand, test, and maintain. For example, a product card, a search form, or a navigation menu can be created as separate components.
|
||||
|
||||
html
|
||||
<!-- product-card.html -->
|
||||
<div class="product-card">
|
||||
<h3>{{ product.name }}</h3>
|
||||
<img src="{{ product.image }}" alt="{{ product.name }}">
|
||||
<p>{{ product.description }}</p>
|
||||
<button hx-post="/add-to-cart/{{ product.id }}">Add to Cart</button>
|
||||
</div>
|
||||
|
||||
|
||||
### 1.5 Code Splitting Strategies
|
||||
|
||||
In htmx, code splitting can refer to different aspects. While htmx itself doesn't require complex JavaScript bundles, consider these:
|
||||
|
||||
* **HTML Components:** Split large pages into smaller, more manageable components. Load these components on demand using htmx requests to improve initial page load time.
|
||||
* **CSS Files:** Separate your CSS into logical modules (e.g., base styles, component styles, page-specific styles) to avoid loading unnecessary styles on every page.
|
||||
* **htmx Extensions:** Only include the htmx extensions that you are actively using. Do not include all extensions if only a few are needed.
|
||||
|
||||
## 2. Common Patterns and Anti-patterns
|
||||
|
||||
### 2.1 Design Patterns Specific to htmx
|
||||
|
||||
* **Progressive Enhancement:** Design your application to work without JavaScript first, then enhance it with htmx. This ensures accessibility and a baseline level of functionality for all users.
|
||||
* **Hypermedia as the Engine of Application State (HATEOAS):** The core philosophy of htmx. The server should provide all the necessary links and forms for the client to interact with the application. The client simply follows these links and submits the forms; it doesn't need to know the specific URLs or request methods.
|
||||
* **Server-Side Rendering (SSR):** Focus on rendering HTML on the server. This improves initial page load time, SEO, and accessibility. htmx enhances this by enabling dynamic updates without full page reloads.
|
||||
* **Component-Based UI:** Design your UI as a collection of reusable components. Each component manages its own state and behavior, making the application easier to understand and maintain.
|
||||
|
||||
### 2.2 Recommended Approaches for Common Tasks
|
||||
|
||||
* **Form Handling:** Use htmx to submit forms and update the UI based on the server's response. Validate user input on both the client and server sides.
|
||||
* **Pagination:** Implement pagination using htmx to load content in chunks. The server provides links to the next and previous pages, and htmx handles the loading and rendering of the new content.
|
||||
* **Real-Time Updates:** Use WebSockets or Server-Sent Events (SSE) with htmx to display real-time data. The server pushes updates to the client, and htmx updates the UI accordingly.
|
||||
* **Dynamic Search:** Implement live search functionality by sending AJAX requests to the server as the user types. Display the search results in real-time using htmx.
|
||||
* **Modal Dialogs:** Use htmx to load the content of modal dialogs on demand. This avoids loading unnecessary content on initial page load.
|
||||
|
||||
### 2.3 Anti-patterns and Code Smells to Avoid
|
||||
|
||||
* **Over-reliance on JavaScript:** htmx aims to reduce the amount of JavaScript required for web development. Avoid using JavaScript for tasks that can be easily accomplished with htmx attributes.
|
||||
* **Complex Client-Side Logic:** Keep your client-side logic as simple as possible. Move complex logic to the server-side, where it can be more easily tested and maintained.
|
||||
* **Mixing htmx with other Front-end frameworks (React, Angular, Vue):** While technically possible, this defeats the purpose of using htmx. Using htmx with other front-end frameworks will likely increase complexity.
|
||||
* **Ignoring Security Best Practices:** htmx does not automatically protect against security vulnerabilities. Always follow security best practices, such as input validation and output escaping, to prevent XSS attacks.
|
||||
* **Creating API Endpoints that return JSON to only convert it to HTML:** htmx shines when your endpoints return HTML. Avoid the extra steps needed for JSON parsing on the client side.
|
||||
|
||||
### 2.4 State Management Best Practices
|
||||
|
||||
htmx promotes a server-centric approach to state management. The server maintains the application's state, and the client simply displays it. This simplifies client-side code and reduces the risk of inconsistencies between the client and server.
|
||||
|
||||
* **Server-Side Sessions:** Store user-specific data in server-side sessions. This ensures that sensitive data is not exposed to the client.
|
||||
* **Hidden Input Fields:** Use hidden input fields to store data that needs to be persisted across requests. This is useful for maintaining state in forms.
|
||||
* **Cookies:** Use cookies to store small amounts of data on the client-side. Be mindful of cookie size limits and security implications.
|
||||
* **URL Parameters:** Use URL parameters to represent state that can be shared or bookmarked. This is useful for implementing features like filtering and sorting.
|
||||
* **`hx-vals`:** Use `hx-vals` for temporary client-side state that is not critical and doesn't need to be persisted on the server. This is suitable for things like the current step in a multi-step form or the visibility state of a component.
|
||||
|
||||
### 2.5 Error Handling Patterns
|
||||
|
||||
* **HTTP Status Codes:** Use appropriate HTTP status codes to indicate the success or failure of a request. For example, use `200 OK` for successful requests, `400 Bad Request` for invalid input, and `500 Internal Server Error` for server-side errors.
|
||||
* **htmx Error Handling:** htmx provides the `htmx:responseError` event for handling errors. Use this event to display error messages to the user or take other appropriate actions.
|
||||
* **Server-Side Error Pages:** Configure your server to display custom error pages for different HTTP status codes. This provides a user-friendly experience even when errors occur.
|
||||
* **Client-Side Error Messages:** Display informative error messages to the user when a request fails. Avoid displaying technical details that could expose sensitive information.
|
||||
* **Error Logging:** Log errors on the server-side to help diagnose and fix problems. Include relevant information such as the request URL, user ID, and error message.
|
||||
* **Graceful Degradation:** Even when errors occur, ensure that your application degrades gracefully. Provide alternative functionality or a clear explanation of the problem.
|
||||
|
||||
## 3. Performance Considerations
|
||||
|
||||
### 3.1 Optimization Techniques
|
||||
|
||||
* **Minimize DOM Updates:** htmx is efficient at updating the DOM, but excessive updates can still impact performance. Use the `hx-swap` attribute to control how content is swapped into the DOM and minimize unnecessary changes.
|
||||
* **Optimize Server-Side Rendering:** Ensure that your server-side rendering is as efficient as possible. Use caching, compression, and other optimization techniques to reduce the time it takes to generate HTML.
|
||||
* **Compress Static Assets:** Compress your CSS, JavaScript, and image files to reduce their size and improve loading times. Use tools like Gzip or Brotli for compression.
|
||||
* **Use a CDN:** Serve your static assets from a Content Delivery Network (CDN) to improve loading times for users around the world.
|
||||
* **Lazy Load Images:** Load images only when they are visible in the viewport. This reduces initial page load time and improves performance.
|
||||
* **Throttle and Debounce Events:** When using events like `keyup` or `mousemove` with `hx-trigger`, use the `throttle` and `debounce` modifiers to limit the number of requests sent to the server.
|
||||
|
||||
### 3.2 Memory Management
|
||||
|
||||
* **Avoid Memory Leaks:** Be careful to avoid memory leaks in your JavaScript code. Remove event listeners when they are no longer needed and avoid creating circular references.
|
||||
* **Minimize DOM Elements:** Reduce the number of DOM elements on your page as much as possible. Complex layouts with many nested elements can impact performance.
|
||||
* **Use Event Delegation:** Use event delegation to attach event listeners to a parent element instead of attaching them to individual child elements. This reduces the number of event listeners and improves performance.
|
||||
|
||||
### 3.3 Rendering Optimization
|
||||
|
||||
* **Use Efficient CSS Selectors:** Use efficient CSS selectors to minimize the time it takes to apply styles to your elements. Avoid complex selectors that traverse the DOM unnecessarily.
|
||||
* **Avoid Reflows and Repaints:** Avoid triggering reflows and repaints in your JavaScript code. These operations can be expensive and impact performance. Read properties before making changes to the DOM, and batch your DOM updates.
|
||||
* **Use Hardware Acceleration:** Take advantage of hardware acceleration to improve rendering performance. Use CSS properties like `transform` and `opacity` to trigger hardware acceleration.
|
||||
|
||||
### 3.4 Bundle Size Optimization
|
||||
|
||||
* **Minimize Dependencies:** Use only the dependencies that you absolutely need. Avoid including large libraries that you only use for a small number of features.
|
||||
* **Tree Shaking:** Use a bundler that supports tree shaking to remove unused code from your JavaScript bundles.
|
||||
* **Code Splitting:** Split your code into smaller chunks that can be loaded on demand. This reduces the initial download size and improves performance.
|
||||
|
||||
### 3.5 Lazy Loading Strategies
|
||||
|
||||
* **Lazy Load Images:** Load images only when they are visible in the viewport. This reduces initial page load time and improves performance. Use the `loading="lazy"` attribute on `<img>` elements.
|
||||
* **Lazy Load Components:** Load components only when they are needed. Use htmx to load the component's HTML when it is first requested.
|
||||
* **Intersection Observer API:** Use the Intersection Observer API to detect when an element enters the viewport. This can be used to trigger the lazy loading of images or components.
|
||||
|
||||
## 4. Security Best Practices
|
||||
|
||||
### 4.1 Common Vulnerabilities and How to Prevent Them
|
||||
|
||||
* **Cross-Site Scripting (XSS):** Prevent XSS attacks by escaping user input and avoiding the use of `innerHTML`. Use template engines that automatically escape output.
|
||||
* **Cross-Site Request Forgery (CSRF):** Protect against CSRF attacks by using anti-CSRF tokens in your forms. Most server-side frameworks provide built-in CSRF protection.
|
||||
* **SQL Injection:** Prevent SQL injection attacks by using parameterized queries or ORMs. Never construct SQL queries by concatenating user input.
|
||||
* **Authentication and Authorization:** Implement proper authentication and authorization mechanisms to protect your application from unauthorized access.
|
||||
* **Sensitive Data Exposure:** Avoid exposing sensitive data in URLs or client-side code. Store sensitive data securely on the server-side.
|
||||
|
||||
### 4.2 Input Validation
|
||||
|
||||
* **Client-Side Validation:** Use client-side validation to provide immediate feedback to the user and prevent invalid data from being submitted to the server. However, never rely solely on client-side validation.
|
||||
* **Server-Side Validation:** Always validate user input on the server-side. This is the only way to ensure that your application is protected from invalid or malicious data.
|
||||
* **Sanitize User Input:** Sanitize user input to remove or escape potentially harmful characters. This can help prevent XSS and other attacks.
|
||||
|
||||
### 4.3 Authentication and Authorization Patterns
|
||||
|
||||
* **Cookie-Based Authentication:** Use cookies to store authentication tokens. Set the `Secure`, `HttpOnly`, and `SameSite` attributes to protect your cookies from unauthorized access.
|
||||
* **Session Management:** Use server-side sessions to store user-specific data. This prevents sensitive data from being exposed to the client.
|
||||
* **Role-Based Access Control (RBAC):** Implement RBAC to control access to different parts of your application based on user roles. This ensures that users can only access the resources that they are authorized to access.
|
||||
|
||||
### 4.4 Data Protection Strategies
|
||||
|
||||
* **Encryption:** Encrypt sensitive data both in transit and at rest. Use HTTPS to encrypt data in transit, and use strong encryption algorithms to encrypt data at rest.
|
||||
* **Hashing:** Use hashing to store passwords and other sensitive data. Never store passwords in plaintext.
|
||||
* **Data Masking:** Mask sensitive data in your application's UI to prevent it from being exposed to unauthorized users. For example, you can mask credit card numbers or social security numbers.
|
||||
|
||||
### 4.5 Secure API Communication
|
||||
|
||||
* **HTTPS:** Always use HTTPS to encrypt communication between the client and server.
|
||||
* **API Authentication:** Require API clients to authenticate themselves before accessing your API. Use API keys, OAuth, or other authentication mechanisms.
|
||||
* **Rate Limiting:** Implement rate limiting to prevent API abuse. This limits the number of requests that a client can make in a given period of time.
|
||||
* **Input Validation:** Validate all input to your API to prevent injection attacks and other security vulnerabilities.
|
||||
* **Output Sanitization:** Sanitize all output from your API to prevent XSS attacks.
|
||||
* **CORS (Cross-Origin Resource Sharing):** Configure CORS carefully to allow only trusted domains to access your API.
|
||||
|
||||
### 4.6 The Golden Rules of htmx Security (reiterated):
|
||||
|
||||
* **Only call routes you control**: Use relative URLs to avoid executing untrusted code.
|
||||
* **Always use an auto-escaping template engine**: Prevent XSS attacks by ensuring dynamic content is escaped.
|
||||
* **Only serve user-generated content inside HTML tags**: Avoid inserting user content in dangerous contexts like script or style tags.
|
||||
* **Secure your cookies**: Use attributes like Secure, HttpOnly, and SameSite=Lax for authentication cookies.
|
||||
|
||||
## 5. Testing Approaches
|
||||
|
||||
### 5.1 Unit Testing Strategies
|
||||
|
||||
* **Test Server-Side Logic:** Write unit tests for your server-side logic to ensure that it is working correctly. Use a testing framework like pytest (Python), Jest (Node.js), or JUnit (Java).
|
||||
* **Test htmx Endpoints:** Write tests for your htmx endpoints. This could involve making requests to your endpoints and checking the HTML responses.
|
||||
* **Mock External Dependencies:** Mock external dependencies, such as databases or APIs, to isolate your code and make your tests more reliable.
|
||||
|
||||
### 5.2 Integration Testing
|
||||
|
||||
* **Test Interactions Between Components:** Write integration tests to ensure that your components are working together correctly. This includes testing the interactions between htmx attributes and JavaScript code.
|
||||
* **Test Data Flow:** Test the flow of data through your application to ensure that data is being processed and displayed correctly.
|
||||
|
||||
### 5.3 End-to-End Testing
|
||||
|
||||
* **Simulate User Interactions:** Write end-to-end tests to simulate user interactions with your application. This includes testing the entire workflow from start to finish.
|
||||
* **Test UI Rendering:** Test the rendering of your UI to ensure that it is displaying correctly. This includes testing the layout, styles, and content of your pages.
|
||||
|
||||
### 5.4 Test Organization
|
||||
|
||||
* **Organize Tests by Feature:** Organize your tests by feature to make it easier to find and run tests for specific parts of your application.
|
||||
* **Use a Consistent Naming Convention:** Use a consistent naming convention for your tests to make them easier to understand and maintain.
|
||||
* **Keep Tests Independent:** Keep your tests independent of each other to avoid cascading failures.
|
||||
|
||||
### 5.5 Mocking and Stubbing
|
||||
|
||||
* **Use Mocking to Isolate Code:** Use mocking to isolate your code and make your tests more reliable. This involves replacing external dependencies with mock objects that simulate their behavior.
|
||||
* **Use Stubbing to Control Behavior:** Use stubbing to control the behavior of your mock objects. This allows you to test different scenarios and edge cases.
|
||||
|
||||
## 6. Common Pitfalls and Gotchas
|
||||
|
||||
### 6.1 Frequent Mistakes Developers Make
|
||||
|
||||
* **Incorrect `hx-target` and `hx-swap` Usage:** Pay close attention to the `hx-target` and `hx-swap` attributes. Incorrect usage can lead to unexpected results and broken UI.
|
||||
* **Forgetting Server-Side Validation:** Always validate user input on the server-side. Client-side validation is not sufficient for security.
|
||||
* **Over-complicating Client-Side Logic:** htmx is designed to simplify client-side code. Avoid adding unnecessary complexity.
|
||||
* **Ignoring Accessibility:** Make sure your htmx application is accessible to all users. Use semantic HTML, provide alternative text for images, and ensure that your application is keyboard-navigable.
|
||||
* **Not handling edge cases and error conditions**: Ensure you have covered the most common error conditions, such as server errors, network issues, and no results.
|
||||
|
||||
### 6.2 Edge Cases to Be Aware Of
|
||||
|
||||
* **Handling Empty Responses:** Consider how your application should behave when the server returns an empty response. Should the target element be cleared, or should a default message be displayed?
|
||||
* **Handling Concurrent Requests:** Be aware of the potential for concurrent requests. Use the `hx-sync` attribute to manage synchronization between requests.
|
||||
* **Handling Browser History:** htmx does not automatically manage browser history. If you need to support browser history, you will need to use JavaScript or a dedicated htmx extension.
|
||||
* **Unexpected interactions with browser extensions**: Some browser extensions, especially those that modify HTTP headers, can interfere with htmx's behavior. Test your application with common extensions enabled to identify and address any conflicts.
|
||||
|
||||
### 6.3 Version-Specific Issues
|
||||
|
||||
* **Refer to the Official Documentation:** Always refer to the official htmx documentation for the latest information and best practices.
|
||||
* **Check Release Notes:** Review the release notes for each new version of htmx to identify any breaking changes or known issues.
|
||||
|
||||
### 6.4 Compatibility Concerns
|
||||
|
||||
* **Browser Compatibility:** htmx is compatible with modern browsers. However, older browsers may require polyfills.
|
||||
* **Server-Side Framework Compatibility:** htmx can be used with any server-side framework that can generate HTML. However, some frameworks may require specific configuration.
|
||||
|
||||
### 6.5 Debugging Strategies
|
||||
|
||||
* **Use Browser Developer Tools:** Use your browser's developer tools to inspect network requests, examine the DOM, and debug JavaScript code.
|
||||
* **htmx Events:** Listen for htmx events, such as `htmx:beforeRequest`, `htmx:afterRequest`, and `htmx:responseError`, to gain insight into what is happening in your application.
|
||||
* **Server-Side Logging:** Add logging to your server-side code to help diagnose problems.
|
||||
* **Simplify the Problem:** Break down complex htmx interactions into smaller, more manageable steps to isolate the source of the problem.
|
||||
* **Inspect HTTP Headers:** Pay attention to the HTTP headers in both the request and response. Check the `Content-Type`, `HX-Request`, and other relevant headers.
|
||||
|
||||
## 7. Tooling and Environment
|
||||
|
||||
### 7.1 Recommended Development Tools
|
||||
|
||||
* **Text Editor or IDE:** Use a text editor or IDE with support for HTML, CSS, and JavaScript. Popular options include VS Code, Sublime Text, and Atom.
|
||||
* **Browser Developer Tools:** Use your browser's developer tools to inspect network requests, examine the DOM, and debug JavaScript code.
|
||||
* **htmx Extension for Chrome:** Install the htmx extension for Chrome to enable features like attribute highlighting and event inspection.
|
||||
* **Server-Side Development Tools:** Use the development tools appropriate for your chosen server-side framework (e.g., Python debugger, Node.js inspector).
|
||||
|
||||
### 7.2 Build Configuration
|
||||
|
||||
* **Use a Task Runner:** Use a task runner like Gulp or Grunt to automate common development tasks, such as minifying CSS and JavaScript, optimizing images, and running tests.
|
||||
* **Use a Module Bundler:** Use a module bundler like Webpack or Parcel to bundle your JavaScript modules into a single file.
|
||||
* **Configure Code Linting and Formatting:** Integrate linters (like ESLint, stylelint) and formatters (like Prettier) to automatically enforce consistent coding styles and catch common errors.
|
||||
|
||||
### 7.3 Linting and Formatting
|
||||
|
||||
* **Use a Code Linter:** Use a code linter to automatically detect errors and enforce coding style guidelines. Popular linters include ESLint (JavaScript) and stylelint (CSS).
|
||||
* **Use a Code Formatter:** Use a code formatter to automatically format your code according to a consistent style. Popular formatters include Prettier and js-beautify.
|
||||
|
||||
### 7.4 Deployment Best Practices
|
||||
|
||||
* **Use a Version Control System:** Use a version control system like Git to track changes to your code. This makes it easier to collaborate with others and revert to previous versions if necessary.
|
||||
* **Automate Deployment:** Automate your deployment process using a tool like Jenkins, Travis CI, or CircleCI. This makes it easier to deploy your application to production quickly and reliably.
|
||||
* **Use a Continuous Integration/Continuous Deployment (CI/CD) Pipeline:** Implement a CI/CD pipeline to automatically build, test, and deploy your application whenever changes are made to your codebase.
|
||||
* **Monitor Your Application:** Monitor your application in production to detect and resolve problems quickly.
|
||||
|
||||
### 7.5 CI/CD Integration
|
||||
|
||||
* **Set Up a CI/CD Pipeline:** Set up a CI/CD pipeline to automatically build, test, and deploy your application. This makes it easier to release new features and bug fixes quickly and reliably.
|
||||
* **Run Tests Automatically:** Configure your CI/CD pipeline to run your tests automatically whenever changes are made to your codebase. This helps to ensure that your code is working correctly before it is deployed to production.
|
||||
* **Automate Deployment:** Automate your deployment process using a tool like Jenkins, Travis CI, or CircleCI. This makes it easier to deploy your application to production quickly and reliably.
|
||||
|
||||
By adhering to these best practices and coding standards, you can build htmx applications that are robust, maintainable, secure, and performant. Remember to stay up-to-date with the latest htmx documentation and community resources to ensure that you are using the most effective techniques.
|
||||
@@ -0,0 +1,353 @@
|
||||
---
|
||||
description: This rule provides comprehensive guidance on tRPC best practices, covering code organization, performance, security, testing, and common pitfalls to ensure robust and maintainable tRPC applications.
|
||||
globs: **/*.{ts,tsx}
|
||||
---
|
||||
# tRPC Best Practices: A Comprehensive Guide
|
||||
|
||||
This document outlines best practices for developing robust, maintainable, and efficient applications using tRPC (TypeScript Remote Procedure Call). It covers various aspects, from code organization to security considerations, providing actionable guidance for developers.
|
||||
|
||||
## 1. Code Organization and Structure
|
||||
|
||||
### 1.1 Directory Structure Best Practices
|
||||
|
||||
* **Feature-Based Organization:** Organize your code around features or modules, rather than technical layers (e.g., `components`, `utils`, `services`). This promotes modularity and maintainability. For example:
|
||||
|
||||
|
||||
src/
|
||||
├── features/
|
||||
│ ├── user/
|
||||
│ │ ├── components/
|
||||
│ │ │ ├── UserProfile.tsx
|
||||
│ │ │ └── UserSettings.tsx
|
||||
│ │ ├── api/
|
||||
│ │ │ ├── userRouter.ts // tRPC router for user-related procedures
|
||||
│ │ │ └── userSchema.ts // Zod schemas for input validation
|
||||
│ │ ├── hooks/
|
||||
│ │ │ └── useUser.ts // Custom hooks for data fetching and state management
|
||||
│ │ └── types/
|
||||
│ │ │ └── user.ts // TypeScript types related to users
|
||||
│ ├── product/
|
||||
│ │ └── ...
|
||||
├── utils/
|
||||
│ ├── api.ts // tRPC client initialization
|
||||
│ └── db.ts // Database connection/abstraction
|
||||
├── app/
|
||||
│ ├── api/
|
||||
│ │ └── root.ts // Root tRPC router combining all feature routers
|
||||
│ └── context.ts // tRPC context creation
|
||||
└── index.ts // Server entry point
|
||||
|
||||
|
||||
* **Separation of Concerns:** Separate concerns into different directories and modules. For instance, keep your tRPC router definitions separate from your business logic and data access layers.
|
||||
* **Grouping Similar Functionality:** Keep related files together within a feature directory. This makes it easier to understand and maintain the code.
|
||||
|
||||
### 1.2 File Naming Conventions
|
||||
|
||||
* **Descriptive Names:** Use descriptive names for files and directories that clearly indicate their purpose.
|
||||
* **Consistent Case:** Maintain a consistent casing convention (e.g., camelCase for variables, PascalCase for components). Use `kebab-case` for file names e.g. `user-profile.tsx` or `user.router.ts`
|
||||
* **Suffixes:** Use suffixes to indicate the type of file (e.g., `.router.ts` for tRPC routers, `.schema.ts` for Zod schemas, `.component.tsx` for React components).
|
||||
|
||||
### 1.3 Module Organization
|
||||
|
||||
* **Small Modules:** Keep modules small and focused. A module should have a single responsibility. Aim for modules that are easy to understand and test.
|
||||
* **Explicit Exports:** Use explicit exports to control what is exposed from a module. This helps to prevent accidental exposure of internal implementation details.
|
||||
* **Circular Dependencies:** Avoid circular dependencies between modules. Circular dependencies can lead to unexpected behavior and make it difficult to reason about the code.
|
||||
|
||||
### 1.4 Component Architecture
|
||||
|
||||
* **Presentational and Container Components:** Separate presentational (dumb) components from container (smart) components. Presentational components focus on rendering UI, while container components handle data fetching and state management. Use the term `view` instead of `component` in the file suffix can make a separation between React components and presentational components, e.g. `user-profile.view.tsx`
|
||||
* **Reusable Components:** Design components to be reusable across different parts of the application. This reduces code duplication and improves maintainability.
|
||||
* **Component Composition:** Favor component composition over inheritance. Composition allows you to create more flexible and reusable components.
|
||||
|
||||
### 1.5 Code Splitting Strategies
|
||||
|
||||
* **Route-Based Splitting:** Split your code based on routes. This allows you to load only the code that is needed for a specific route. This can be easily achieved with React's `lazy` and `Suspense` APIs.
|
||||
* **Component-Based Splitting:** Split your code based on components. This allows you to load only the code that is needed for a specific component.
|
||||
* **Dynamic Imports:** Use dynamic imports to load code on demand. This can be useful for loading large libraries or components that are not needed immediately.
|
||||
|
||||
## 2. Common Patterns and Anti-patterns
|
||||
|
||||
### 2.1 Design Patterns Specific to tRPC
|
||||
|
||||
* **Router Composition:** Compose tRPC routers to create a hierarchical API structure. This allows you to organize your API into logical groups.
|
||||
|
||||
typescript
|
||||
// src/app/api/routers/userRouter.ts
|
||||
import { publicProcedure, router } from "../trpc";
|
||||
import { z } from "zod";
|
||||
|
||||
export const userRouter = router({
|
||||
getById: publicProcedure
|
||||
.input(z.string())
|
||||
.query(async ({ input }) => {
|
||||
// ... fetch user by ID
|
||||
}),
|
||||
create: publicProcedure
|
||||
.input(z.object({ name: z.string() }))
|
||||
.mutation(async ({ input }) => {
|
||||
// ... create a new user
|
||||
}),
|
||||
});
|
||||
|
||||
// src/app/api/root.ts
|
||||
import { userRouter } from "./routers/userRouter";
|
||||
import { productRouter } from "./routers/productRouter";
|
||||
|
||||
export const appRouter = router({
|
||||
user: userRouter,
|
||||
product: productRouter,
|
||||
});
|
||||
|
||||
export type AppRouter = typeof appRouter;
|
||||
|
||||
|
||||
* **Middleware Chaining:** Use middleware to handle cross-cutting concerns such as authentication, authorization, and logging. Middleware can be chained to create a pipeline of operations.
|
||||
|
||||
typescript
|
||||
// src/app/api/trpc.ts
|
||||
import { initTRPC, TRPCError } from "@trpc/server";
|
||||
import { Context } from "./context";
|
||||
|
||||
const t = initTRPC.context<Context>().create();
|
||||
const isAuthed = t.middleware(({ ctx, next }) => {
|
||||
if (!ctx.user) {
|
||||
throw new TRPCError({ code: "UNAUTHORIZED" });
|
||||
}
|
||||
return next({
|
||||
ctx: {
|
||||
user: ctx.user,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
export const router = t.router;
|
||||
export const publicProcedure = t.procedure;
|
||||
export const protectedProcedure = t.procedure.use(isAuthed);
|
||||
|
||||
|
||||
* **Input Validation with Zod:** Use Zod for input validation to ensure that data received from the client is valid. This helps to prevent errors and security vulnerabilities.
|
||||
|
||||
typescript
|
||||
import { z } from "zod";
|
||||
import { publicProcedure } from "../trpc";
|
||||
|
||||
export const createUserProcedure = publicProcedure
|
||||
.input(z.object({ name: z.string().min(3), email: z.string().email() }))
|
||||
.mutation(async ({ input }) => {
|
||||
// ... create a new user
|
||||
});
|
||||
|
||||
|
||||
### 2.2 Recommended Approaches for Common Tasks
|
||||
|
||||
* **Authentication:** Use tRPC middleware to authenticate users. Verify user credentials and set the user object in the context.
|
||||
* **Authorization:** Use tRPC middleware to authorize users. Check if the user has the required permissions to access a resource.
|
||||
* **Error Handling:** Use tRPC's built-in error handling mechanisms to handle errors gracefully. Throw `TRPCError` exceptions with appropriate error codes and messages.
|
||||
* **Data Fetching:** Use a data fetching library (e.g., Prisma, Drizzle ORM, Supabase) to interact with your database. Abstract data access logic into separate modules or services.
|
||||
|
||||
### 2.3 Anti-patterns and Code Smells to Avoid
|
||||
|
||||
* **Over-fetching:** Avoid fetching more data than you need. Use projections or GraphQL-style queries to fetch only the required fields.
|
||||
* **Under-fetching:** Avoid making multiple API calls to fetch related data. Batch requests or use a data loader pattern to fetch related data in a single call.
|
||||
* **Tight Coupling:** Avoid tight coupling between tRPC routers and your business logic. Abstract business logic into separate modules or services.
|
||||
* **Ignoring Errors:** Never ignore errors. Always handle errors gracefully and provide meaningful feedback to the client.
|
||||
* **Direct Database Access in Routers:** Avoid accessing the database directly within tRPC router procedures. Instead, abstract data access into separate services or repositories.
|
||||
* **Complex Business Logic in Routers:** Keep tRPC router procedures focused on routing and input validation. Move complex business logic to separate functions or modules.
|
||||
|
||||
### 2.4 State Management Best Practices
|
||||
|
||||
* **Centralized State Management:** Use a centralized state management library (e.g., Zustand, Redux, Jotai) to manage application state. This makes it easier to share state between components and to reason about the application's state.
|
||||
* **Immutable State:** Use immutable state to prevent unexpected side effects. This makes it easier to reason about the application's state and to debug issues.
|
||||
* **Controlled Components:** Use controlled components to manage form state. This gives you more control over the form and makes it easier to validate input.
|
||||
* **Server State Management:** Use a library like TanStack Query or SWR to manage server state (data fetched from the API). These libraries provide caching, optimistic updates, and other features that make it easier to manage server state.
|
||||
|
||||
### 2.5 Error Handling Patterns
|
||||
|
||||
* **Centralized Error Handling:** Use a centralized error handling mechanism to handle errors consistently across the application.
|
||||
* **Error Boundaries:** Use error boundaries to prevent errors from crashing the application. Error boundaries can catch errors that occur during rendering and display a fallback UI.
|
||||
* **Logging:** Log errors to a central logging service. This makes it easier to track down and fix issues.
|
||||
* **User-Friendly Error Messages:** Display user-friendly error messages to the user. Avoid displaying technical details or stack traces.
|
||||
* **Retry Mechanism:** Implement a retry mechanism for transient errors. This can improve the resilience of the application.
|
||||
|
||||
## 3. Performance Considerations
|
||||
|
||||
### 3.1 Optimization Techniques
|
||||
|
||||
* **Caching:** Implement caching to reduce the number of API calls. Cache data on the server and the client.
|
||||
* **Compression:** Use compression to reduce the size of API responses. This can improve the performance of the application, especially on slow networks.
|
||||
* **Code Splitting:** Split your code into smaller chunks to reduce the initial load time. Load code on demand as needed.
|
||||
* **Debouncing and Throttling:** Use debouncing and throttling to reduce the number of API calls triggered by user input.
|
||||
* **Efficient Data Structures:** Use efficient data structures to store and process data. Choose the right data structure for the task at hand.
|
||||
|
||||
### 3.2 Memory Management
|
||||
|
||||
* **Avoid Memory Leaks:** Be careful to avoid memory leaks. Memory leaks can cause the application to slow down and eventually crash.
|
||||
* **Garbage Collection:** Understand how garbage collection works in JavaScript. This can help you to avoid memory leaks and to optimize memory usage.
|
||||
* **Use Weak References:** Use weak references to avoid keeping objects in memory longer than necessary.
|
||||
|
||||
### 3.3 Rendering Optimization
|
||||
|
||||
* **Memoization:** Use memoization to avoid re-rendering components unnecessarily. Memoize components that receive the same props multiple times.
|
||||
* **Virtualization:** Use virtualization to render large lists efficiently. Virtualization only renders the items that are visible on the screen.
|
||||
* **Batch Updates:** Batch updates to reduce the number of re-renders. React's `useState` hook batches updates automatically.
|
||||
|
||||
### 3.4 Bundle Size Optimization
|
||||
|
||||
* **Tree Shaking:** Use tree shaking to remove unused code from the bundle. This can significantly reduce the bundle size.
|
||||
* **Code Minification:** Minify your code to reduce the bundle size. Minification removes whitespace and comments from the code.
|
||||
* **Image Optimization:** Optimize images to reduce the bundle size. Use appropriate image formats and compress images.
|
||||
* **Dependency Analysis:** Analyze your dependencies to identify large or unnecessary dependencies. Consider replacing large dependencies with smaller alternatives.
|
||||
|
||||
### 3.5 Lazy Loading Strategies
|
||||
|
||||
* **Lazy Load Images:** Lazy load images to improve the initial load time. Only load images when they are visible on the screen.
|
||||
* **Lazy Load Components:** Lazy load components to improve the initial load time. Only load components when they are needed.
|
||||
* **Lazy Load Modules:** Lazy load modules to improve the initial load time. Only load modules when they are needed.
|
||||
|
||||
## 4. Security Best Practices
|
||||
|
||||
### 4.1 Common Vulnerabilities and How to Prevent Them
|
||||
|
||||
* **Cross-Site Scripting (XSS):** Prevent XSS attacks by escaping user input and using a content security policy (CSP).
|
||||
* **Cross-Site Request Forgery (CSRF):** Prevent CSRF attacks by using CSRF tokens. Most frameworks have built-in support for CSRF protection.
|
||||
* **SQL Injection:** Prevent SQL injection attacks by using parameterized queries or an ORM.
|
||||
* **Authentication and Authorization:** Implement strong authentication and authorization mechanisms to protect sensitive data.
|
||||
* **Rate Limiting:** Implement rate limiting to prevent brute-force attacks.
|
||||
* **Denial-of-Service (DoS):** Implement measures to prevent DoS attacks, such as rate limiting and input validation.
|
||||
|
||||
### 4.2 Input Validation
|
||||
|
||||
* **Validate All Input:** Validate all input from the client, including query parameters, request bodies, and headers.
|
||||
* **Use Strong Types:** Use strong types to define the expected format of input data. This can help to prevent type-related errors and security vulnerabilities. Tools like Zod are invaluable here.
|
||||
* **Sanitize Input:** Sanitize input to remove potentially harmful characters or code. This can help to prevent XSS attacks.
|
||||
* **Whitelist Input:** Whitelist allowed input values. This is more secure than blacklisting disallowed values.
|
||||
|
||||
### 4.3 Authentication and Authorization Patterns
|
||||
|
||||
* **JWT (JSON Web Tokens):** Use JWTs for authentication. JWTs are a standard way to securely transmit information between parties as a JSON object.
|
||||
* **OAuth 2.0:** Use OAuth 2.0 for authorization. OAuth 2.0 is a standard protocol for delegating access to resources.
|
||||
* **Role-Based Access Control (RBAC):** Use RBAC to control access to resources based on user roles. This makes it easier to manage permissions and to enforce security policies.
|
||||
* **Attribute-Based Access Control (ABAC):** Use ABAC to control access to resources based on user attributes. This provides more fine-grained control over access to resources.
|
||||
|
||||
### 4.4 Data Protection Strategies
|
||||
|
||||
* **Encryption:** Encrypt sensitive data at rest and in transit. Use strong encryption algorithms.
|
||||
* **Hashing:** Hash passwords and other sensitive data. Use a strong hashing algorithm with a salt.
|
||||
* **Data Masking:** Mask sensitive data in logs and other outputs. This prevents sensitive data from being exposed accidentally.
|
||||
* **Data Redaction:** Redact sensitive data from API responses. This prevents sensitive data from being exposed to unauthorized users.
|
||||
|
||||
### 4.5 Secure API Communication
|
||||
|
||||
* **HTTPS:** Use HTTPS for all API communication. HTTPS encrypts the communication between the client and the server, protecting it from eavesdropping and tampering.
|
||||
* **CORS (Cross-Origin Resource Sharing):** Configure CORS to restrict access to your API from unauthorized domains. This helps to prevent cross-site scripting attacks.
|
||||
* **Rate Limiting:** Implement rate limiting to prevent brute-force attacks and DoS attacks.
|
||||
* **API Keys:** Use API keys to authenticate API clients. This helps to prevent unauthorized access to your API.
|
||||
|
||||
## 5. Testing Approaches
|
||||
|
||||
### 5.1 Unit Testing Strategies
|
||||
|
||||
* **Test Individual Functions and Modules:** Unit tests should focus on testing individual functions and modules in isolation.
|
||||
* **Mock Dependencies:** Mock dependencies to isolate the code under test. This prevents external dependencies from interfering with the test.
|
||||
* **Test Edge Cases:** Test edge cases to ensure that the code handles unexpected input correctly.
|
||||
* **Test Error Handling:** Test error handling to ensure that the code handles errors gracefully.
|
||||
* **Use Test-Driven Development (TDD):** Consider using TDD to write tests before writing code. This can help to improve the design of the code and to ensure that it is testable.
|
||||
|
||||
### 5.2 Integration Testing
|
||||
|
||||
* **Test Interactions Between Modules:** Integration tests should focus on testing the interactions between modules. This ensures that the modules work together correctly.
|
||||
* **Use Real Dependencies:** Use real dependencies in integration tests. This provides more realistic testing conditions.
|
||||
* **Test Data Flow:** Test the data flow between modules to ensure that data is passed correctly.
|
||||
|
||||
### 5.3 End-to-End Testing
|
||||
|
||||
* **Test the Entire Application:** End-to-end tests should focus on testing the entire application, from the user interface to the backend API.
|
||||
* **Use a Test Automation Framework:** Use a test automation framework (e.g., Cypress, Playwright) to automate end-to-end tests. This makes it easier to run the tests and to verify that the application is working correctly.
|
||||
* **Test User Flows:** Test common user flows to ensure that users can complete important tasks.
|
||||
|
||||
### 5.4 Test Organization
|
||||
|
||||
* **Organize Tests by Feature:** Organize tests by feature. This makes it easier to find and run tests for a specific feature.
|
||||
* **Keep Tests Separate from Code:** Keep tests separate from the code. This prevents tests from being included in the production bundle.
|
||||
* **Use a Consistent Naming Convention:** Use a consistent naming convention for tests. This makes it easier to identify and understand the tests.
|
||||
|
||||
### 5.5 Mocking and Stubbing
|
||||
|
||||
* **Use Mocking Frameworks:** Use mocking frameworks (e.g., Jest, Sinon) to create mocks and stubs. This makes it easier to isolate the code under test.
|
||||
* **Mock External Dependencies:** Mock external dependencies to prevent them from interfering with the test.
|
||||
* **Stub API Responses:** Stub API responses to control the data that is returned by the API.
|
||||
|
||||
## 6. Common Pitfalls and Gotchas
|
||||
|
||||
### 6.1 Frequent Mistakes Developers Make
|
||||
|
||||
* **Not Validating Input:** Failing to validate input is a common mistake that can lead to errors and security vulnerabilities.
|
||||
* **Ignoring Errors:** Ignoring errors can make it difficult to debug issues and can lead to unexpected behavior.
|
||||
* **Over-Complicating Code:** Over-complicating code can make it difficult to understand and maintain.
|
||||
* **Not Writing Tests:** Not writing tests can lead to bugs and can make it difficult to refactor the code.
|
||||
* **Incorrect Context Usage:** Misunderstanding how the tRPC context works, especially when dealing with middleware and authentication.
|
||||
|
||||
### 6.2 Edge Cases to Be Aware Of
|
||||
|
||||
* **Empty Input:** Handle empty input gracefully. Provide default values or display an error message.
|
||||
* **Invalid Input:** Handle invalid input gracefully. Display an error message to the user.
|
||||
* **Network Errors:** Handle network errors gracefully. Display an error message to the user and provide a way to retry the request.
|
||||
* **Server Errors:** Handle server errors gracefully. Display an error message to the user and log the error on the server.
|
||||
* **Concurrency Issues:** Be aware of concurrency issues when dealing with shared resources. Use locks or other synchronization mechanisms to prevent data corruption.
|
||||
|
||||
### 6.3 Version-Specific Issues
|
||||
|
||||
* **Breaking Changes:** Be aware of breaking changes when upgrading tRPC. Review the release notes carefully and update your code accordingly.
|
||||
* **Deprecated Features:** Be aware of deprecated features. Replace deprecated features with the recommended alternatives.
|
||||
* **Compatibility Issues:** Be aware of compatibility issues with other libraries. Test your code thoroughly after upgrading tRPC or other libraries.
|
||||
|
||||
### 6.4 Compatibility Concerns
|
||||
|
||||
* **Browser Compatibility:** Ensure that your code is compatible with the browsers that you support.
|
||||
* **Node.js Version Compatibility:** Ensure that your code is compatible with the Node.js versions that you support.
|
||||
* **TypeScript Version Compatibility:** Ensure that your code is compatible with the TypeScript version that you are using.
|
||||
|
||||
### 6.5 Debugging Strategies
|
||||
|
||||
* **Use Debugging Tools:** Use debugging tools (e.g., Chrome DevTools, VS Code debugger) to step through your code and inspect variables.
|
||||
* **Add Logging Statements:** Add logging statements to your code to track the flow of execution and to identify errors.
|
||||
* **Use a Debugger:** Use a debugger to pause the execution of your code and to inspect the state of the application.
|
||||
* **Reproduce the Issue:** Try to reproduce the issue in a controlled environment. This makes it easier to identify the cause of the issue.
|
||||
|
||||
## 7. Tooling and Environment
|
||||
|
||||
### 7.1 Recommended Development Tools
|
||||
|
||||
* **VS Code:** Use VS Code as your IDE. VS Code provides excellent support for TypeScript and JavaScript development.
|
||||
* **ESLint:** Use ESLint to enforce code style and to prevent errors.
|
||||
* **Prettier:** Use Prettier to format your code automatically.
|
||||
* **TypeScript Compiler:** Use the TypeScript compiler to compile your code.
|
||||
* **npm or Yarn:** Use npm or Yarn to manage your dependencies.
|
||||
* **Testing Framework:** Jest is a great testing framework
|
||||
|
||||
### 7.2 Build Configuration
|
||||
|
||||
* **Use a Build Tool:** Use a build tool (e.g., Webpack, Parcel, Rollup) to bundle your code for production.
|
||||
* **Configure the Build Tool:** Configure the build tool to optimize the bundle size, to minify the code, and to perform tree shaking.
|
||||
* **Use Environment Variables:** Use environment variables to configure the build process.
|
||||
|
||||
### 7.3 Linting and Formatting
|
||||
|
||||
* **Configure ESLint:** Configure ESLint to enforce code style and to prevent errors. Use a consistent code style across the entire project.
|
||||
* **Configure Prettier:** Configure Prettier to format your code automatically. This ensures that the code is consistently formatted.
|
||||
* **Use a Pre-Commit Hook:** Use a pre-commit hook to run ESLint and Prettier before committing code. This prevents code with style violations or errors from being committed.
|
||||
|
||||
### 7.4 Deployment Best Practices
|
||||
|
||||
* **Use a Deployment Platform:** Use a deployment platform (e.g., Vercel, Netlify, AWS) to deploy your application.
|
||||
* **Configure the Deployment Platform:** Configure the deployment platform to automatically deploy your application when changes are pushed to the repository.
|
||||
* **Use Environment Variables:** Use environment variables to configure the deployment environment.
|
||||
* **Monitor the Application:** Monitor the application to identify and resolve issues.
|
||||
|
||||
### 7.5 CI/CD Integration
|
||||
|
||||
* **Use a CI/CD Tool:** Use a CI/CD tool (e.g., GitHub Actions, GitLab CI, CircleCI) to automate the build, test, and deployment process.
|
||||
* **Configure the CI/CD Tool:** Configure the CI/CD tool to run tests, build the application, and deploy the application automatically.
|
||||
* **Use Environment Variables:** Use environment variables to configure the CI/CD environment.
|
||||
|
||||
By adhering to these best practices, you can build robust, maintainable, and efficient applications using tRPC.
|
||||
Reference in New Issue
Block a user