"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.fastifyDecoratorPlugin = void 0;
const fastify_plugin_1 = __importDefault(require("fastify-plugin"));
function fastifyDecoratorPlugin(identifier, make) {
    const plugin = (fastify, _opts, done) => {
        const object = make(fastify);
        fastify.decorate(identifier, object);
        fastify.addHook("onClose", async () => {
            await object.close();
        });
        done();
    };
    return (0, fastify_plugin_1.default)(plugin);
}
exports.fastifyDecoratorPlugin = fastifyDecoratorPlugin;
//# sourceMappingURL=fastify-decorator-plugin.js.map