Server.d.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { Middleware, Route } from '../base/http';
  2. import { Logger, Message } from '../base/logger';
  3. import { ServerProperties } from './ServerProperties';
  4. /** @sealed */
  5. declare class Server {
  6. private instance;
  7. private readonly port;
  8. private readonly logger;
  9. private i18n;
  10. static readonly i18nDefaultPath = "../resources/i18n.json";
  11. static readonly defaultMiddlewaresPath = "../middlewares";
  12. static readonly defaultRoutesPath = "../routes";
  13. private readonly httpHandlers;
  14. private initialized;
  15. private readonly i18nPath?;
  16. private readonly middlewaresPath?;
  17. private readonly routesPath?;
  18. private readonly viewEngine?;
  19. private readonly viewsPath?;
  20. private readonly options?;
  21. constructor(properties: ServerProperties);
  22. init(): Promise<Server>;
  23. private postInit;
  24. private processHttpHandlers;
  25. addMiddleware(middleware: Middleware): Server;
  26. addRoute(route: Route): Server;
  27. logInfo(message: string): void;
  28. logError(message: string): void;
  29. logWarn(message: string): void;
  30. log(message: Message): void;
  31. private get;
  32. private post;
  33. registerRoutes(dir: string): Promise<Server>;
  34. registerMiddlewares(dir: string): Promise<Server>;
  35. getLogger(): Logger;
  36. i18nLoad(path: string): Server;
  37. getOption(key: string): any;
  38. start(callback?: () => any): void;
  39. }
  40. export { Server };