Server.d.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { Middleware, Route } from '../base/http';
  2. import { Logger, Message } from '../base/logger';
  3. import { ServerProperties } from './ServerProperties';
  4. import { WebSocket as WS } from 'ws';
  5. /** @sealed */
  6. declare class Server {
  7. private instance;
  8. private httpServer;
  9. private readonly port;
  10. private readonly host;
  11. private readonly logger;
  12. private i18n;
  13. static readonly i18nDefaultPath = "../resources/i18n.json";
  14. static readonly defaultMiddlewaresPath = "../middlewares";
  15. static readonly defaultRoutesPath = "../routes";
  16. private readonly httpHandlers;
  17. private readonly wsHandlers;
  18. private readonly wsServers;
  19. private initialized;
  20. private readonly i18nPath?;
  21. private readonly middlewaresPath?;
  22. private readonly routesPath?;
  23. private readonly viewEngine?;
  24. private readonly viewsPath?;
  25. private readonly options?;
  26. private readonly swaggerDocsPath?;
  27. private readonly swaggerTitle?;
  28. private readonly swaggerDescription?;
  29. private readonly swaggerApiVersion?;
  30. private readonly swaggerRoute?;
  31. constructor(properties: ServerProperties);
  32. init(): Promise<Server>;
  33. private postInit;
  34. private processHttpHandlers;
  35. addMiddleware(middleware: Middleware): Server;
  36. addRoute(route: Route): Server;
  37. private registerRoutesDocumentation;
  38. registerWsServers(): Server;
  39. applyWsHandlers(): Server;
  40. getWsConnections(url: string): Set<WS> | null;
  41. logInfo(message: string): void;
  42. logError(message: string): void;
  43. logWarn(message: string): void;
  44. log(message: Message): void;
  45. private get;
  46. private post;
  47. private registerSwaggerMiddleware;
  48. registerRoutes(dir: string): Promise<Server>;
  49. registerMiddlewares(dir: string): Promise<Server>;
  50. getLogger(): Logger;
  51. i18nLoad(path: string): Server;
  52. getOption(key: string): any;
  53. start(callback?: () => any): void;
  54. }
  55. export { Server };