// /plugins/services.ts
import fp from "fastify-plugin";
import { bankStatementService } from "../modules/cron/bankstatementsync.service";
import {syncDokuboxService} from "../modules/cron/dokuboximport.service";
import { FastifyInstance } from "fastify";
import {prepareIncomingInvoices} from "../modules/cron/prepareIncomingInvoices";

declare module "fastify" {
    interface FastifyInstance {
        services: {
            bankStatements: ReturnType<typeof bankStatementService>;
            dokuboxSync: ReturnType<typeof syncDokuboxService>;
            prepareIncomingInvoices: ReturnType<typeof prepareIncomingInvoices>;
        };
    }
}

export default fp(async function servicePlugin(server: FastifyInstance) {
    server.decorate("services", {
        bankStatements: bankStatementService(server),
        dokuboxSync: syncDokuboxService(server),
        prepareIncomingInvoices: prepareIncomingInvoices(server),
    });
});
