"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CronJob = exports.Queue = void 0;
const client_1 = require("./client");
const config_1 = require("./client/config");
(0, config_1.registerDevelopmentDefaults)({
    applicationPort: 3000,
});
function Queue(route, handler, options) {
    const quirrel = new client_1.QuirrelClient({
        options,
        handler,
        route,
    });
    async function nextApiHandler(req, res) {
        const response = await quirrel.respondTo(req.body, req.headers);
        res.status(response.status);
        for (const [header, value] of Object.entries(response.headers)) {
            res.setHeader(header, value);
        }
        res.send(response.body);
    }
    nextApiHandler.enqueue = (payload, options) => quirrel.enqueue(payload, options);
    nextApiHandler.enqueueMany = (jobs) => quirrel.enqueueMany(jobs);
    nextApiHandler.delete = (jobId) => quirrel.delete(jobId);
    nextApiHandler.invoke = (jobId) => quirrel.invoke(jobId);
    nextApiHandler.get = () => quirrel.get();
    nextApiHandler.getById = (jobId) => quirrel.getById(jobId);
    return nextApiHandler;
}
exports.Queue = Queue;
function CronJob(route, cronSchedule, handler, options) {
    return Queue(route, handler, options);
}
exports.CronJob = CronJob;
//# sourceMappingURL=next.js.map