import pkg from "beanstalkd"; import type { Handle } from "@sveltejs/kit"; // Annoying CommonJS interop issue (vitejs/vite#2139) which combines with incorrect typings from DefinitelyTyped project :( // @ts-ignore const BeanstalkdClient = pkg.default as typeof pkg; export const beanstalkdHandle = (async ({ event, resolve }) => { // FIXME: Should obv. read from env. const beanstalkdClient = new BeanstalkdClient("localhost", 11300); await beanstalkdClient.connect(); event.locals.beanstalkdClient = beanstalkdClient; try { return await resolve(event); } finally { beanstalkdClient.quit(); } }) satisfies Handle;