UNPKG

signalk-server

Version:

An implementation of a [Signal K](http://signalk.org) server for boats.

50 lines 2.29 kB
import { Request, Application } from 'express'; import { Reply, RequestState } from './requestResponse'; import { ConfigApp } from './config/config'; import { WithSecurityStrategy } from './security'; interface WsInterface { canHandlePut: (path: string, source: string | undefined) => boolean; handlePut: (requestId: string, context: string, path: string, source: string | undefined, value: unknown) => Promise<Reply>; } interface PutAppInterfaces { ws?: WsInterface; [key: string]: unknown; } interface PutApp extends Application { config: ConfigApp['config']; intervals: NodeJS.Timeout[]; interfaces: PutAppInterfaces; signalk: ConfigApp['signalk']; handleMessage: ConfigApp['handleMessage']; securityStrategy: WithSecurityStrategy['securityStrategy']; registerActionHandler?: typeof registerActionHandler; deRegisterActionHandler?: typeof deRegisterActionHandler; } interface PathApp { intervals: NodeJS.Timeout[]; interfaces: PutAppInterfaces; securityStrategy: WithSecurityStrategy['securityStrategy']; } type ActionCallback = (reply: ActionResult) => void; interface ActionResult { state: RequestState | 'SUCCESS' | 'FAILURE' | 'PENDING'; statusCode?: number; message?: string; } type ActionHandler = (context: string, path: string, value: unknown, callback: ActionCallback) => ActionResult | void; interface PutBody { value: unknown; source?: string; } interface SkRequest extends Request { skPrincipal?: { identifier: string; }; } export declare function start(app: PutApp): void; export declare function deletePath(app: PathApp, contextParam: string | null, path: string, req?: SkRequest | null, requestId?: string | null, updateCb?: (reply: Reply) => void): Promise<Reply>; export declare function putPath(app: PathApp, contextParam: string | null, path: string, body: PutBody, req?: SkRequest | null, requestId?: string | null, updateCb?: (reply: Reply) => void): Promise<Reply>; export declare function registerActionHandler(context: string, path: string, source: string, callback: ActionHandler): () => void; export declare function deRegisterActionHandler(context: string, path: string, source: string, callback: ActionHandler): void; export {}; //# sourceMappingURL=put.d.ts.map