@piggly/fastify-chassis
Version:
An ESM/CommonJS toolkit to help you to do common operations in your back-end applications with Fastify and NodeJS.
61 lines • 1.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FastifyModifiers = void 0;
/**
* @file The Fastify modifier.
* @copyright Piggly Lab 2023
*/
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;
}
}
exports.FastifyModifiers = FastifyModifiers;
//# sourceMappingURL=FastifyModifiers.js.map