18 lines
530 B
JavaScript
18 lines
530 B
JavaScript
import { parentPort } from 'worker_threads';
|
|
import {NameCardCreator} from "./nameCardCreator.js";
|
|
|
|
parentPort.on("message", async (data) => {
|
|
try {
|
|
const { templatePath, avatarURL, username } = data;
|
|
|
|
const creator = new NameCardCreator(templatePath);
|
|
const buffer = await creator.getWelcomeCard(avatarURL, username);
|
|
|
|
parentPort.postMessage({ result: buffer });
|
|
|
|
} catch (err) {
|
|
parentPort.postMessage({ error: err.message });
|
|
} finally {
|
|
parentPort.close();
|
|
}
|
|
}); |