Recently, I've been attempting to import faktory_worker_node from github.com/jbielick/faktory_worker. The README provides the following instructions:
const faktory = require('faktory-worker');
faktory.register('ResizeImage', async ({ id, size }) => {
const image = await Image.find(id);
await image.resize(size);
});
faktory.work();
In an effort to translate it into Typescript, I made the following adjustments:
import faktory from 'faktory-worker';
faktory.register('ResizeImage', async ({ id, size }) => {
const image = await Image.find(id);
await image.resize(size);
});
faktory.work();
Despite my efforts, I keep encountering the error message
TypeError: Cannot read property 'register' of undefined
. It seems like I need to use const
to properly create an object, but I'm struggling to grasp the concept.
While I could continue using this syntax, Typescript guidelines recommend following the rule
no-var-requires: require statement not part of an import statement