import { QuirrelClient, } from "./client";
import { registerDevelopmentDefaults } from "./client/config";
registerDevelopmentDefaults({
    applicationPort: 8911,
});
function decodeBase64(v) {
    return Buffer.from(v, "base64").toString("utf8");
}
export function Queue(route, handler, options) {
    const quirrel = new 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;
}
export function CronJob(route, cronSchedule, handler, options) {
    return Queue(route, handler, options);
}
//# sourceMappingURL=redwood.js.map