UNPKG

@icoms-detection/server-esp32

Version:

This is the OFFICIAL SERVER library created by Icoms Detection to run their apps.

53 lines (52 loc) 1.51 kB
/// <reference types="node" /> import { PassThrough } from "stream"; import * as http from "http"; export interface ApiFunction { (req: http.IncomingMessage, res: http.ServerResponse): void | Promise<void>; } /** * Allowed http methods */ export declare enum HttpMethods { GET = "GET", POST = "POST", DELETE = "DELETE" } export declare type ServerTypes = { start: (port?: number) => void; end: () => void; get: (route: string, func: ApiFunction) => void; post: (route: string, func: ApiFunction) => void; deleteRequest: (route: string, func: ApiFunction) => void; setDirectory: (path: string, main: string) => void; }; export declare type Wifi = { ssid: string; password: string; }; export declare type WifiVerification = { isOK: boolean; message: string; }; /** * UART command * @param cmd String with the message to send * @param stream Duplex stream to get the response from the UART * @param validation Function to specify when the UART response is end * @param timeout Milliseconds to wait before closing the stream if validation isn't finish yet */ export interface CommandTypes { cmd: Buffer; stream: PassThrough; validation?: (buff: Buffer) => boolean; timeout?: number; } export declare type UartConfiguration = { baud: number; pinRX: number; pinTX: number; }; export interface DeviceTypes { sendCommand: (command: CommandTypes) => void; } export declare type ExtendedPlatform = NodeJS.Platform | "esp32";