UNPKG

@piggly/fastify-chassis

Version:

An ESM/CommonJS toolkit to help you to do common operations in your back-end applications with Fastify and NodeJS.

113 lines (112 loc) 2.85 kB
import { LoggerService } from '@piggly/ddd-toolkit'; import type { ApiDefaultEnvironment, HttpServerInterface, ApiServerInterface } from '../types/index.js'; /** * @file The HTTP server. * @copyright Piggly Lab 2023 */ export declare class HttpServer<AppEnvironment extends ApiDefaultEnvironment> implements HttpServerInterface<any, AppEnvironment> { /** * The API server. * * @protected * @memberof HttpServer * @since 1.0.0 * @author Caique Araujo <caique@piggly.com.br> */ protected _api: ApiServerInterface<any, AppEnvironment>; /** * The running state. * * @type {boolean} * @protected * @memberof HttpServer * @since 1.0.0 * @author Caique Araujo <caique@piggly.com.br> */ protected _running: boolean; /** * Create a new HTTP server. * * @param api The API server. * @public * @constructor * @memberof HttpServer * @since 1.0.0 * @author Caique Araujo <caique@piggly.com.br> */ constructor(api: ApiServerInterface<any, AppEnvironment>); /** * Get the API server. * * @public * @memberof HttpServer * @since 1.0.0 * @author Caique Araujo <caique@piggly.com.br> */ getApi(): ApiServerInterface<any, AppEnvironment>; /** * Check if the server is running. * * @returns {boolean} * @public * @memberof HttpServer * @since 1.0.0 * @author Caique Araujo <caique@piggly.com.br> */ isRunning(): boolean; /** * Restart the server. * * @returns {Promise<boolean>} * @public * @async * @memberof HttpServer * @since 1.0.0 * @author Caique Araujo <caique@piggly.com.br> */ restart(): Promise<boolean>; /** * Start the server. * It will auto add current server to cleanup service if it is registered. * * @returns {Promise<boolean>} * @public * @async * @memberof HttpServer * @since 1.0.0 * @author Caique Araujo <caique@piggly.com.br> */ start(): Promise<boolean>; /** * Stop the server. * * @returns {Promise<boolean>} * @public * @async * @memberof HttpServer * @since 1.0.0 * @author Caique Araujo <caique@piggly.com.br> */ stop(): Promise<boolean>; /** * Get the logger. * * @returns {LoggerService} * @protected * @memberof HttpServer * @since 5.4.0 * @author Caique Araujo <caique@piggly.com.br> */ protected getLogger(): LoggerService; /** * Listen to the server. * * @returns {Promise<boolean>} * @protected * @async * @memberof HttpServer * @since 1.0.0 * @author Caique Araujo <caique@piggly.com.br> */ protected listen(): Promise<boolean>; }