All checks were successful
farmcontrol/farmcontrol-ws/pipeline/head This commit looks good
- Updated the `notificationUserFromOwner` function to support 'marketplace' as a valid owner type. - Added a new `marketplaceEvent` schema to manage marketplace events, including fields for `externalReference`, `topic`, and `status`. - Enhanced existing schemas (e.g., `orderitem`, `shipment`, `client`, `listing`, `listingVarient`, `salesOrder`, `courierService`) to include `externalReference` fields for better integration with external systems. - Introduced unique indexes for `externalReference` in relevant schemas to ensure data integrity and prevent duplicates. - Improved the `marketplace` schema to include additional fields for eBay shipping services, enhancing its configurability.
FarmControl WebSocket Service
A WebSocket microservice for FarmControl that handles real-time communication and distributed locking.
Features
- Real-time WebSocket communication
- Distributed locking
- Keycloak authentication integration
- MongoDB integration for user management
- Event streaming and notifications
Prerequisites
- Node.js (v16 or higher)
- MongoDB server
- Redis server
- Keycloak server (for authentication)
Installation
- Clone the repository
- Install dependencies:
npm install
Configuration
The application uses config.json for configuration. Update the following sections:
MongoDB Configuration
{
"database": {
"mongo": {
"url": "mongodb://localhost:27017/farmcontrol"
}
}
}
Authentication Configuration
{
"auth": {
"enabled": true,
"keycloak": {
"url": "https://your-keycloak-server",
"realm": "your-realm",
"clientId": "your-client-id"
}
}
}
Running the Application
Development
npm run dev
Production
npm start
API Endpoints
The service exposes WebSocket endpoints for:
- Lock management: Lock/unlock objects with real-time notifications
- Authentication: Keycloak-based authentication
- Real-time updates: Stream-based event notifications
Development
Project Structure
src/
├── auth/ # Authentication logic
├── database/ # Database connections (redis, mongo)
├── lock/ # Distributed locking
├── notification/ # Notification management
├── socket/ # WebSocket handling
└── index.js # Main application entry point
Adding New Features
- Database operations: Use the
redisServerinstance for Redis operations - WebSocket events: Extend the
SocketUserclass - Authentication: Extend the
KeycloakAuthclass
Troubleshooting
Common Issues
- Redis connection failed: Ensure Redis is running on the configured host and port
- Authentication errors: Verify Keycloak configuration and credentials
- MongoDB connection issues: Check MongoDB server status and connection string
Logging
The application uses log4js for logging. Set the log level in the configuration:
{
"server": {
"logLevel": "debug"
}
}
Available log levels: trace, debug, info, warn, error
Languages
JavaScript
100%