@piggly/fastify-chassis
Version:
An ESM/CommonJS toolkit to help you to do common operations in your back-end applications with Fastify and NodeJS.
57 lines • 1.39 kB
JavaScript
/**
* @file The Fastify modifier.
* @copyright Piggly Lab 2023
*/
export class FastifyModifiers {
/**
* The callables
*
* @type {Array<FastifyModifierCallable>}
* @memberof FastifyModifier
* @since 1.0.0
* @author Caique Araujo <caique@piggly.com.br>
*/
_callables = [];
/**
* Create a new Fastify modifier.
*
* @param {Array<FastifyModifierCallable>} args The callables.
* @public
* @constructor
* @memberof FastifyModifier
* @since 1.0.0
* @author Caique Araujo <caique@piggly.com.br>
*/
constructor(...args) {
this._callables = args;
}
/**
* Apply the modifier.
*
* @param app The Fastify application.
* @param env The environment.
* @returns {Promise<void>}
* @public
* @memberof FastifyModifier
* @since 1.0.0
* @author Caique Araujo <caique@piggly.com.br>
*/
async apply(app, env) {
await Promise.all(this._callables.map(async (callable) => {
await callable(app, env);
}));
}
/**
* Get the size of callables.
*
* @returns {number}
* @public
* @memberof FastifyModifier
* @since 1.0.0
* @author Caique Araujo <caique@piggly.com.br>
*/
size() {
return this._callables.length;
}
}
//# sourceMappingURL=FastifyModifiers.js.map