Repository navigation
Releases: davidesantangelo/node-red
Release list
v0.2.0
What's New
Structured Error Classes
Error handling is now much more robust and informative. All API errors now include contextual information to help you diagnose issues faster:
begin
client.flows
rescue Node::Red::BadRequestError => e
puts "Status: #{e.status}" # => 400
puts "Code: #{e.code}" # => "invalid_request"
puts "Details: #{e.details.inspect}" # => Full parsed response body
endNew error classes:
BadRequestError- Raised for HTTP 400 responses (malformed requests)ConflictError- Raised for HTTP 409 responses (version conflicts)UnexpectedResponseError- Raised for unexpected response types
Enhanced existing errors:
AuthenticationError- Now includes structured context (HTTP 401)NotFoundError- Now includes structured context (HTTP 404)ServerError- Now includes structured context (HTTP 5xx)
Comprehensive Test Coverage
Added extensive WebMock-backed RSpec tests covering:
- ✅ Every Admin API endpoint (auth, flows, nodes, settings, diagnostics)
- ✅ All error paths and edge cases
- ✅ Authorization header handling
- ✅ Empty response bodies
- ✅ Invalid JSON responses
- ✅ Various HTTP status codes
This ensures reliability and makes future contributions easier!
Improvements
Better Error Handling
The client now intelligently maps Node-RED response codes to dedicated exceptions:
- 400 →
BadRequestError - 401 →
AuthenticationError - 404 →
NotFoundError - 409 →
ConflictError - 5xx →
ServerError - Other unexpected responses →
UnexpectedResponseError
Enhanced JSON Parsing
Response and error parsing now includes safeguards for:
- Empty response bodies
- Invalid JSON
- Missing error fields
- Malformed content
This prevents cryptic parsing errors and provides clearer diagnostics.
Updated Documentation
The README now includes advanced error-handling guidance with examples showing how to access error context for debugging.
Dependencies
Added webmock ~> 3.19 for HTTP request stubbing in tests.
Migration Guide
If you're upgrading from v0.1.0, no breaking changes were introduced! Your existing code will continue to work. However, you can now optionally access richer error information:
Before:
rescue Node::Red::ApiError => e
puts e.message
endAfter (optional enhancement):
rescue Node::Red::ApiError => e
puts "Error: #{e.message}"
puts "HTTP Status: #{e.status}"
puts "Error Code: #{e.code}" if e.code
puts "Details: #{e.details.inspect}" if e.details
endFull Changelog: [View on GitHub](https://github.com/your-repo/node-red-ruby/compare/v0.1.0...v0.2.0)
v0.1.0
Added
Core Features
- Initial release of Node-RED Admin HTTP API Ruby client
- Complete implementation of all 21 Node-RED Admin API endpoints
- Comprehensive RDoc documentation for all public methods
Authentication Support (3 endpoints)
auth_login- Get active authentication schemeauth_token- Exchange credentials for access token with automatic token managementauth_revoke- Revoke access tokens
Settings & Diagnostics (2 endpoints)
settings- Get runtime settings and configurationdiagnostics- Get runtime diagnostics information
Flow Management (8 endpoints)
flows- Get active flow configurationflows_state- Get flow runtime statedeploy_flows- Deploy complete flow configuration with revision supportset_flows_state- Start/stop flows at runtimeadd_flow- Add individual flows to configurationflow- Get specific flow configurationupdate_flow- Update individual flow configurationdelete_flow- Delete individual flows
Node Management (8 endpoints)
nodes- List all installed node modulesinstall_node- Install new node modules from npmnode_module- Get node module informationupdate_node_module- Enable/disable node modulesdelete_node_module- Remove node modulesnode_set- Get node set informationupdate_node_set- Enable/disable node sets
Error Handling
ApiError- Base error class for all API errorsAuthenticationError- Raised on authentication failures (401)NotFoundError- Raised when resources are not found (404)ServerError- Raised on server errors (5xx)- Intelligent error message parsing from API responses
Developer Experience
- Three comprehensive example files demonstrating usage:
examples/basic_usage.rb- Basic API operationsexamples/flow_management.rb- Flow CRUD operationsexamples/node_management.rb- Node module management
- RSpec test suite with basic coverage
- RuboCop configuration for code quality
- Detailed README with usage examples for all endpoints
- MIT License
Technical Details
- Minimum Ruby version: 3.1.0
- Zero external dependencies (uses only Ruby stdlib)
- HTTP client built on
Net::HTTP - JSON parsing with stdlib
json - Automatic Bearer token management after authentication
- Support for both HTTP and HTTPS connections
Notes
- All dangerous operations (install/delete/enable/disable) are commented out in examples for safety
- API follows Node-RED Admin API specification exactly
- Fully compatible with Node-RED 1.0.0+