UNPKG

iopa

Version:

API-first, Internet of Things (IoT) stack for Typescript, official implementation of the Internet Open Protocols Alliance (IOPA) reference pattern

56 lines 2.41 kB
import type { FC, IRef, IopaApp, IPlugin, IContextCore, IAppProperties, IAppCapabilityLegacy, IContextIopa, IMap, AppHandler, IRouterApp, IConfig, DefaultHandler } from '@iopa/types'; import Middleware from './middleware'; declare type MiddlewareFC<C = any> = FC<C> & { id: string; }; export default class AppBuilder<P = any, C = any> implements IopaApp<P, C> { properties: IMap<IAppProperties<C>>; private _middleware; middlewareProxy: typeof Middleware; private _factory; private _abortController; constructor(appProperties?: Partial<IAppProperties<C>>, appOptions?: Partial<IAppCapabilityLegacy>); private _dispose; private _abort; private _exception; capability<T>(keyOrRef: IRef<T>): T | undefined; private _capability; setCapability<K extends keyof C>(keyOrRef: K, value: C[K]): any; private _setCapability; createContext(urlOrRequest?: string | Request, options?: any): IContextIopa<C>; fork(when: (context: any) => boolean): IopaApp<P, C>; use(mw: any, id: string, options: unknown): this; use(mw: any, id: string): this; use(mw: any): this; use(method: 'invoke' | 'dispatch', mw?: any): this; dispose(): void; build(): FC<C> & { properties: IMap<IAppProperties<C>>; dispatch: MiddlewareFC<C>; }; private _buildDynamic; dispatch(context: IContextCore<C>): any; invoke(context: IContextCore<C>): Promise<void>; childInvoke(context: IContextIopa<C>, handler: DefaultHandler & { id?: string; }, id?: string): Promise<void>; private _compose; usePlugin(plugin: IPlugin<P, C>): this; } export declare class RouterApp extends AppBuilder implements IRouterApp { head: (path: string, handler: AppHandler) => this; post: (path: string, handler: AppHandler) => this; get: (path: string, handler: AppHandler) => this; options: (path: string, handler: AppHandler) => this; put: (path: string, handler: AppHandler) => this; delete: (path: string, handler: AppHandler) => this; patch: (path: string, handler: AppHandler) => this; all: (path: string, handler: AppHandler) => this; config: IConfig; constructor(appProperties?: Partial<IAppProperties<any>>, appOptions?: Partial<IAppCapabilityLegacy>); registerFeatureFlag(flagOptions: { name: string; }): this; } export {}; //# sourceMappingURL=appBuilder.d.ts.map