@piggly/fastify-chassis
Version:
An ESM/CommonJS toolkit to help you to do common operations in your back-end applications with Fastify and NodeJS.
94 lines (93 loc) • 2.35 kB
TypeScript
/**
* @file Handle clean up check services.
* @copyright Piggly Lab 2024
*/
export declare class CleanUpService {
/**
* Handlers to check.
*
* @type {Map<string, () => Promise<boolean>>}
* @protected
* @memberof CleanUpService
* @since 5.2.0
* @author Caique Araujo <caique@piggly.com.br>
*/
protected handlers: Map<string, () => Promise<boolean>>;
/**
* Constructor.
*
* @public
* @constructor
* @memberof CleanUpService
* @since 5.2.0
* @author Caique Araujo <caique@piggly.com.br>
*/
constructor();
/**
* Check all handlers.
*
* @returns {Promise<{
* success: boolean;
* services: Record<string, boolean>;
* }>}
* @public
* @memberof CleanUpService
* @since 5.3.0
* @throws {Error} If any handler fails.
* @author Caique Araujo <caique@piggly.com.br>
*/
clean(): Promise<{
services: Record<string, boolean>;
success: boolean;
}>;
/**
* Register a new handler.
*
* @param {string} name
* @param {() => Promise<boolean>} handler
* @public
* @memberof CleanUpService
* @since 5.2.0
* @author Caique Araujo <caique@piggly.com.br>
*/
register(name: string, handler: () => Promise<boolean>): void;
/**
* Check all handlers. It will not throw any error.
*
* @returns {Promise<{
* success: boolean;
* services: Record<string, boolean>;
* }>}
* @public
* @memberof CleanUpService
* @since 5.3.0
* @author Caique Araujo <caique@piggly.com.br>
*/
softClean(): Promise<{
services: Record<string, boolean>;
success: boolean;
}>;
/**
* Register application service.
*
* @param {CleanUpService} service
* @public
* @static
* @memberof CleanUpService
* @since 5.2.0
* @author Caique Araujo <caique@piggly.com.br>
*/
static register(service: CleanUpService): void;
/**
* Resolve application service.
*
* @returns {CleanUpService}
* @throws {Error} If service is not registered.
* @public
* @static
* @memberof CleanUpService
* @since 5.2.0
* @author Caique Araujo <caique@piggly.com.br>
*/
static resolve(): CleanUpService;
}