"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: 8911,
});
function decodeBase64(v) {
    return Buffer.from(v, "base64").toString("utf8");
}
function Queue(route, handler, options) {
    const quirrel = new client_1.QuirrelClient({
        options,
        handler,
        route,
    });
    async function redwoodHandler(event) {
        const { body, headers, status } = await quirrel.respondTo(event.isBase64Encoded ? decodeBase64(event.body) : event.body, event.headers);
        return {
            statusCode: status,
            body,
            headers,
        };
    }
    redwoodHandler.enqueue = (payload, options) => quirrel.enqueue(payload, options);
    redwoodHandler.enqueueMany = (jobs) => quirrel.enqueueMany(jobs);
    redwoodHandler.delete = (jobId) => quirrel.delete(jobId);
    redwoodHandler.invoke = (jobId) => quirrel.invoke(jobId);
    redwoodHandler.get = () => quirrel.get();
    redwoodHandler.getById = (jobId) => quirrel.getById(jobId);
    return redwoodHandler;
}
exports.Queue = Queue;
function CronJob(route, cronSchedule, handler, options) {
    return Queue(route, handler, options);
}
exports.CronJob = CronJob;
//# sourceMappingURL=redwood.js.map