const workerResult = await new Promise((resolve, reject) => {
const worker = new Worker(__filename, {
workerData: {
data: data,
options: options,
}
});
worker.on('message', resolve);
worker.on('error', reject);
worker.on('exit', (code) => {
if (code !== 0) {
reject(new Error(`Worker stopped with exit code ${code}`));
}
worker.terminate()
});
});
return workerResult
};
transform.middleware = function(req, res, next) {