fix bruno collection
This commit is contained in:
@@ -12,6 +12,7 @@ A personal stock screener and portfolio tracker. Scores stocks, ETFs, and bonds
|
||||
- [Running Tests](#running-tests)
|
||||
- [Project Structure](#project-structure)
|
||||
- [User Guide](#user-guide)
|
||||
- [API Testing with Bruno](#api-testing-with-bruno)
|
||||
|
||||
---
|
||||
|
||||
@@ -19,8 +20,16 @@ A personal stock screener and portfolio tracker. Scores stocks, ETFs, and bonds
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Node.js 20+
|
||||
- npm 10+
|
||||
- **Node.js 20+** (v22 recommended)
|
||||
- **npm 10+**
|
||||
|
||||
**Check your versions:**
|
||||
```bash
|
||||
node --version # Should output v20.x.x or higher
|
||||
npm --version # Should output 10.x.x or higher
|
||||
```
|
||||
|
||||
**Not on Node 20+?** See [NODE_VERSION_FIX.md](./NODE_VERSION_FIX.md) for upgrade instructions.
|
||||
|
||||
### Install
|
||||
|
||||
@@ -322,3 +331,276 @@ A filtered view showing only tickers with a **✅ Strong Buy** signal across bot
|
||||
### API rate limits
|
||||
|
||||
`/api/screen`, `/api/screen/catalysts`, and `/api/analyze` are capped at **10 requests per minute** per IP. All other routes allow 60 per minute.
|
||||
|
||||
---
|
||||
|
||||
## API Testing with Bruno
|
||||
|
||||
### What is Bruno?
|
||||
|
||||
[Bruno](https://www.usebruno.com/) is a lightweight, open-source API client that's Git-friendly and perfect for testing REST APIs. It stores collections as plain text files instead of JSON blobs, making them easy to version control and collaborate on.
|
||||
|
||||
### Installing Bruno
|
||||
|
||||
#### macOS (via Homebrew)
|
||||
```bash
|
||||
brew install bruno
|
||||
```
|
||||
|
||||
#### macOS (Direct Download)
|
||||
1. Visit [usebruno.com/downloads](https://www.usebruno.com/downloads)
|
||||
2. Download the macOS version
|
||||
3. Drag `Bruno.app` to Applications folder
|
||||
|
||||
#### Windows
|
||||
1. Visit [usebruno.com/downloads](https://www.usebruno.com/downloads)
|
||||
2. Download the Windows installer (.exe)
|
||||
3. Run the installer and follow the prompts
|
||||
4. Or via Chocolatey: `choco install bruno`
|
||||
|
||||
#### Linux (Ubuntu/Debian)
|
||||
```bash
|
||||
# Add Bruno repository
|
||||
curl -1sLf 'https://dl.usebruno.com/install.sh' | sudo bash
|
||||
|
||||
# Install
|
||||
sudo apt-get install bruno
|
||||
```
|
||||
|
||||
#### Linux (Fedora/RHEL)
|
||||
```bash
|
||||
curl -1sLf 'https://dl.usebruno.com/install.sh' | sudo bash
|
||||
sudo dnf install bruno
|
||||
```
|
||||
|
||||
### Installing Bruno CLI (brucli)
|
||||
|
||||
For running tests from the command line without the GUI:
|
||||
|
||||
#### macOS
|
||||
```bash
|
||||
brew install brucli
|
||||
```
|
||||
|
||||
#### Windows
|
||||
```bash
|
||||
choco install bruno-cli
|
||||
```
|
||||
|
||||
#### Linux
|
||||
```bash
|
||||
curl -1sLf 'https://dl.usebruno.com/install.sh' | sudo bash
|
||||
```
|
||||
|
||||
### Importing the API Collection
|
||||
|
||||
#### Method 1: Import via Bruno GUI (Easiest)
|
||||
|
||||
1. **Open Bruno**
|
||||
2. **File → Import Collection**
|
||||
3. **Select** `api_collections/market-screener.postman_collection.json`
|
||||
4. **Choose location** where to save the converted collection (e.g., `api_collections/market-screener`)
|
||||
5. **Click Import** — Bruno automatically converts and structures the collection
|
||||
|
||||
#### Method 2: Import via Bruno CLI
|
||||
|
||||
```bash
|
||||
# Navigate to the project root
|
||||
cd market-screener
|
||||
|
||||
# Import the Postman collection
|
||||
bru import api_collections/market-screener.postman_collection.json -o api_collections/market-screener
|
||||
|
||||
# Output: Collection imported to api_collections/market-screener/
|
||||
```
|
||||
|
||||
#### Method 3: Convert Postman to Bruno Format (Manual)
|
||||
|
||||
If you prefer to manually convert the collection:
|
||||
|
||||
```bash
|
||||
# Install conversion dependencies (if needed)
|
||||
pip install requests
|
||||
|
||||
# Run the conversion script
|
||||
python3 api_collections/convert_postman_to_bruno.py \
|
||||
api_collections/market-screener.postman_collection.json \
|
||||
api_collections/market-screener
|
||||
```
|
||||
|
||||
### Running Tests
|
||||
|
||||
#### Via Bruno GUI
|
||||
|
||||
1. **Open the imported collection** in Bruno
|
||||
2. **Set the `baseUrl` variable** (default: `http://localhost:3000`)
|
||||
3. **Click the Play button** to run all tests
|
||||
4. **View results** for each request in the UI
|
||||
|
||||
#### Via Bruno CLI (brucli)
|
||||
|
||||
```bash
|
||||
# Navigate to the collection directory
|
||||
cd api_collections/market-screener
|
||||
|
||||
# Run all tests in the collection
|
||||
bru run
|
||||
|
||||
# Run with specific environment
|
||||
bru run --env local
|
||||
|
||||
# Run with output format
|
||||
bru run --output json > test-results.json
|
||||
|
||||
# Run specific test file
|
||||
bru run "Screener/Screen - Mixed.bru"
|
||||
```
|
||||
|
||||
### Collection Structure
|
||||
|
||||
After import, you'll have:
|
||||
|
||||
```
|
||||
api_collections/market-screener/
|
||||
├── bruno.json # Collection metadata
|
||||
├── Health/
|
||||
│ └── Health Check.bru
|
||||
├── Screener/
|
||||
│ ├── Screen - Mixed.bru
|
||||
│ ├── Screen - Tech Stocks.bru
|
||||
│ ├── Screen - REIT.bru
|
||||
│ ├── Validation empty tickers.bru
|
||||
│ ├── Validation 50 plus tickers.bru
|
||||
│ └── Get Catalysts.bru
|
||||
├── Market Context/
|
||||
│ └── Get Market Context.bru
|
||||
├── Portfolio/
|
||||
│ ├── Add Holding AAPL.bru
|
||||
│ ├── Add Holding VOO.bru
|
||||
│ ├── Add Holding BTC-USD.bru
|
||||
│ ├── Add Holding Validation.bru
|
||||
│ ├── Get Portfolio.bru
|
||||
│ ├── Remove Holding AAPL.bru
|
||||
│ └── Remove Holding Non-existent.bru
|
||||
├── Market Calls/
|
||||
│ ├── List Calls.bru
|
||||
│ ├── Create Market Call.bru
|
||||
│ ├── Get Call by ID.bru
|
||||
│ ├── Get Call Non-existent.bru
|
||||
│ ├── Get Earnings Calendar.bru
|
||||
│ ├── Get Calendar Specific Tickers.bru
|
||||
│ ├── Create Call Validation.bru
|
||||
│ ├── Delete Call.bru
|
||||
│ └── Delete Call Already Deleted.bru
|
||||
└── LLM Analysis/
|
||||
├── Analyze Tickers.bru
|
||||
└── Analyze Validation.bru
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
#### Setting Variables
|
||||
|
||||
Variables are stored in `bruno.json` and can be overridden per request:
|
||||
|
||||
**Default variables:**
|
||||
- `baseUrl`: `http://localhost:3000`
|
||||
- `callId`: (auto-populated by Create Market Call request)
|
||||
|
||||
To change variables in the GUI:
|
||||
1. Right-click collection → **Settings**
|
||||
2. Click **Variables** tab
|
||||
3. Edit `baseUrl` or other variables
|
||||
4. Click **Save**
|
||||
|
||||
#### Environment Files
|
||||
|
||||
Create a `.env.bruno` file in the collection directory for local overrides:
|
||||
|
||||
```env
|
||||
baseUrl=http://localhost:3000
|
||||
apiKey=your-secret-key
|
||||
```
|
||||
|
||||
### Common Workflows
|
||||
|
||||
#### 1. Test the full API flow
|
||||
|
||||
```bash
|
||||
cd api_collections/market-screener
|
||||
bru run
|
||||
```
|
||||
|
||||
#### 2. Test just the Screener endpoints
|
||||
|
||||
```bash
|
||||
cd api_collections/market-screener
|
||||
bru run "Screener"
|
||||
```
|
||||
|
||||
#### 3. Test and save results
|
||||
|
||||
```bash
|
||||
cd api_collections/market-screener
|
||||
bru run --output json > test-results-$(date +%Y%m%d).json
|
||||
```
|
||||
|
||||
#### 4. Continuous testing (while developing)
|
||||
|
||||
```bash
|
||||
# Terminal 1: Run the API server
|
||||
npm run dev
|
||||
|
||||
# Terminal 2: Watch and run tests every 5 seconds
|
||||
cd api_collections/market-screener
|
||||
watch -n 5 'bru run'
|
||||
```
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
#### "You can run only at the root of a collection" error
|
||||
|
||||
Make sure you're in the correct directory:
|
||||
|
||||
```bash
|
||||
# ❌ Wrong — project root
|
||||
cd market-screener
|
||||
bru run
|
||||
|
||||
# ✅ Correct — collection root
|
||||
cd api_collections/market-screener
|
||||
bru run
|
||||
```
|
||||
|
||||
#### Variables not found
|
||||
|
||||
Verify variable names in `bruno.json`:
|
||||
|
||||
```bash
|
||||
# Check variables
|
||||
cat api_collections/market-screener/bruno.json | grep -A 10 "vars"
|
||||
```
|
||||
|
||||
#### Tests failing with "undefined" errors
|
||||
|
||||
Common causes:
|
||||
- Variable name mismatch (case-sensitive)
|
||||
- Server not running on the expected port
|
||||
- Port conflict (try `lsof -i :3000` to check)
|
||||
|
||||
### Postman vs Bruno
|
||||
|
||||
| Feature | Postman | Bruno |
|
||||
|---------|---------|-------|
|
||||
| **Download Size** | ~380MB | ~50MB |
|
||||
| **Collection Format** | Single JSON blob | Plain text `.bru` files |
|
||||
| **Git-Friendly** | ❌ Binary | ✅ Text-based, diffable |
|
||||
| **API Response** | UI-only | CLI + GUI |
|
||||
| **Cost** | Free tier + paid | ✅ Completely free |
|
||||
| **IDE Integration** | None | Can edit `.bru` files directly |
|
||||
|
||||
### References
|
||||
|
||||
- **Bruno Docs**: [docs.usebruno.com](https://docs.usebruno.com)
|
||||
- **Bruno GitHub**: [github.com/usebruno/bruno](https://github.com/usebruno/bruno)
|
||||
- **Postman Collection**: `api_collections/market-screener.postman_collection.json`
|
||||
|
||||
Reference in New Issue
Block a user