JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 56
  • Score
    100M100P100Q106147F
  • License MIT

Common utilities for both infrastructure services and business services

Package Exports

  • @onlineapps/service-common
  • @onlineapps/service-common/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@onlineapps/service-common) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@onlineapps/service-common

Common utilities for both infrastructure services and business services in OA Drive.

Purpose

This library provides shared functionality that is used across the entire system, by both infrastructure services (Gateway, Registry, Validator, etc.) and business services (hello-service, etc.).

Installation

npm install @onlineapps/service-common

Usage

Wait for Infrastructure Ready

Wait for all infrastructure services to be ready before creating queues:

Infrastructure Services:

const { waitForInfrastructureReady } = require('@onlineapps/service-common');

await waitForInfrastructureReady({
  redisUrl: 'redis://api_node_cache:6379',
  maxWait: 300000, // 5 minutes
  checkInterval: 5000, // 5 seconds
  logger: logger
});

// Now safe to create infrastructure queues

Business Services:

const { waitForInfrastructureReady } = require('@onlineapps/service-common');

await waitForInfrastructureReady({
  redisUrl: process.env.REDIS_URL,
  maxWait: 60000, // 1 minute
  checkInterval: 5000, // 5 seconds
  logger: logger
});

// Now safe to create business queues

API

waitForInfrastructureReady(options)

Waits for all infrastructure services to be reported as healthy by Registry.

Options:

  • redisUrl (string): Redis URL (default: from ENV or redis://api_node_cache:6379)
  • maxWait (number): Maximum wait time in ms (default: 300000 = 5 minutes)
  • checkInterval (number): Check interval in ms (default: 5000 = 5 seconds)
  • logger (Object): Logger instance (default: console)

Returns: Promise<boolean> - True if all infrastructure services are ready

Throws: Error - If timeout is reached

Environment Variables:

  • REDIS_URL - Redis connection URL
  • INFRASTRUCTURE_HEALTH_WAIT_MAX_TIME - Maximum wait time in ms
  • INFRASTRUCTURE_HEALTH_WAIT_CHECK_INTERVAL - Check interval in ms

Architecture

This library is used by:

  • Infrastructure services (via @onlineapps/infrastructure-tools which re-exports from here)
  • Business services (via @onlineapps/service-wrapper or directly)

This ensures no duplication and consistent behavior across all services.