/** * @author Martin Karkowski * @email m.karkowski@zema.de * @desc [description] */ import { getCentralDecoratedContainer, IexportFunctionAsNopeServiceParameters, } from "./container"; const CONTAINER = getCentralDecoratedContainer(); /** * Defintion of a Functon. */ export type callable = { (...args): T; }; /** * Decorator, that will export the Function to a Dispatcher * @param func The Function * @param options The Options. */ export function exportFunctionAsNopeService( func: T, options: IexportFunctionAsNopeServiceParameters ) { // Only add the element if it doesnt exists. if (!CONTAINER.methods.has(options.id)) { CONTAINER.methods.set(options.id, { callback: async (...args) => { return await (func as any)(...args); }, options, uri: options.id || (func as any).name, }); } return func; }