UNPKG

digitaltwin-core

Version:

Minimalist framework to collect and handle data in a Digital Twin project

47 lines 1.96 kB
/** * @fileoverview HTTP endpoint exposure utilities for digital twin components * * This module handles the automatic registration of HTTP endpoints from servable * components to the Express router, enabling RESTful API access to digital twin data. */ import type { Router } from 'ultimate-express'; import type { Collector } from '../components/collector.js'; import type { Harvester } from '../components/harvester.js'; import type { Handler } from '../components/handler.js'; import type { AssetsManager, CustomTableManager } from '../components/index.js'; /** * Supported HTTP methods for component endpoints. * * These methods correspond to standard REST operations: * - get: Retrieve data * - post: Create new resources * - put: Update existing resources (full update) * - patch: Update existing resources (partial update) * - delete: Remove resources */ export type HttpMethod = 'get' | 'post' | 'put' | 'delete' | 'patch'; /** * Automatically registers HTTP endpoints from servable components to an Express router. * * This function iterates through all provided components, extracts their endpoints, * and registers them with the Express router. Each endpoint is wrapped with error * handling to ensure robust API behavior. * * @param router - Express router instance to register endpoints with * @param servables - Array of components that expose HTTP endpoints * * @throws {Error} When an unsupported HTTP method is encountered * * @example * ```typescript * const router = express.Router(); * const components = [collector1, harvester1, assetsManager1]; * * await exposeEndpoints(router, components); * * // Now the router has all endpoints from the components registered * app.use('/api', router); * ``` */ export declare function exposeEndpoints(router: Router, servables: Array<Collector | Harvester | Handler | AssetsManager | CustomTableManager>): Promise<void>; //# sourceMappingURL=endpoints.d.ts.map