## ๐Ÿ“„ README.md ### ๐Ÿš€ API Endpoint Mason Brick A smart, synchronized generator that appends API logic across `Comms`, `ConnectComms`, and `AppDataManager` while handling auto-imports and optional formatting. ### ๐Ÿ›  1. First-Time Setup Run these commands to ensure Mason and the Dart hooks are ready to go: ```bash # 1. Install Mason CLI (if you haven't) dart pub global activate mason_cli # 2. Initialize Mason in project root mason init # 3. Install Hook dependencies cd bricks/api_endpoint/hooks dart pub get cd ../../../ # 4. Register the brick mason get ``` ### ๐Ÿ”ƒ 2. How to Refresh (When logic or prompts change) If you update the `brick.yaml` or the `post_gen.dart` hook, Mason might use a cached version. Use this "Hard Refresh" command: ```bash rm -rf .mason && mason get ``` ### ๐Ÿƒ 3. Running the Generator To add a new endpoint, simply run: ```bash mason make api_endpoint ``` **Interaction Flow:** 1. **Endpoint Path:** e.g., `orders/confirm` 2. **Function Name:** e.g., `confirmOrder` 3. **Method:** Choose `get` or `post`. 4. **Request Body:** * **Mandatory for POST**: e.g., `OrderDetails`. * **Optional for GET**: Leave empty or provide a type like `String`. 5. **Auto-Import**: The brick scans `lib/` for your Body type and adds the `import` statement automatically. 6. **Format**: Choose `y` to run `dart format` on all 4 modified files. --- ## ๐Ÿš setup_brick.sh Create this file in your project root to allow one-click setup or refreshing for your team. ```bash #!/bin/bash # setup_brick.sh echo "๐Ÿงน Cleaning old Mason cache..." rm -rf .mason echo "๐Ÿ“ฆ Fetching Hook dependencies..." if [ -d "bricks/api_endpoint/hooks" ]; then cd bricks/api_endpoint/hooks dart pub get cd ../../../ else echo "โŒ Error: bricks/api_endpoint/hooks directory not found!" exit 1 fi echo "๐Ÿงฑ Registering Mason Brick..." mason get echo "โœ… Setup Complete! Run 'mason make api_endpoint' to start." ``` ### To use the script: 1. Create the file: `touch setup_brick.sh` 2. Give it permission: `chmod +x setup_brick.sh` 3. Run it: `./setup_brick.sh` --- ### ๐Ÿ’ก Pro-Tip: Project Name Detection In your `post_gen.dart` hook, ensure you have updated the `package:your_project_name` string to match your real project name from `pubspec.yaml`, otherwise the auto-imports will show a red error in VS Code.