Tom Butcher 4b2f4c4bf8
All checks were successful
farmcontrol/farmcontrol-ws/pipeline/head This commit looks good
Add text indexes to various schemas for improved search capabilities
- Introduced text indexes in invoice, payment, tax record, and multiple inventory and management schemas to enhance search functionality.
- Updated schemas include invoice, payment, tax record, filament stock, order item, part stock, product stock, purchase order, shipment, stock audit, stock event, stock location, stock transfer, app password, audit log, courier, courier service, document job, document printer, document size, document template, filament, filament SKU, file, host, material, note type, part, part SKU, product, product category, product SKU, tax rate, user, vendor, gcode file, job, printer, subjob, client, listing, listing variant, and marketplace schemas.
- Improved search performance and flexibility across the application by leveraging text indexing.
2026-07-04 22:03:31 +01:00
2025-12-13 23:54:25 +00:00
2026-06-21 13:19:18 +01:00
2026-06-20 22:06:15 +01:00
2025-12-14 00:25:57 +00:00
2026-06-21 13:19:18 +01:00
2026-02-01 21:51:49 +00:00
2025-12-29 02:40:15 +00:00

FarmControl WebSocket Service

Build Status

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

  1. Clone the repository
  2. 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

  1. Database operations: Use the redisServer instance for Redis operations
  2. WebSocket events: Extend the SocketUser class
  3. Authentication: Extend the KeycloakAuth class

Troubleshooting

Common Issues

  1. Redis connection failed: Ensure Redis is running on the configured host and port
  2. Authentication errors: Verify Keycloak configuration and credentials
  3. 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

Description
A WebSocket microservice for FarmControl that handles real-time communication and distributed locking using etcd.
Readme 1.6 MiB
Languages
JavaScript 98.8%
CSS 0.7%
EJS 0.5%