Multi-thread support for applyTemplate
This commit is contained in:
parent
f7e84e3ee7
commit
bfb07c633d
10 changed files with 1260 additions and 154 deletions
29
workers/docx.worker.ts
Normal file
29
workers/docx.worker.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import {
|
||||
applyTemplate,
|
||||
type DocumentTemplate
|
||||
} from '../lib/lib-tmpl';
|
||||
|
||||
interface DocxWorkerInput {
|
||||
templateBuffer: Uint8Array;
|
||||
templateData: DocumentTemplate;
|
||||
secret: string;
|
||||
privateKeyHex: string;
|
||||
ticketSec: number;
|
||||
}
|
||||
|
||||
export default async function generateDocx(
|
||||
input: DocxWorkerInput
|
||||
): Promise<Buffer> {
|
||||
|
||||
const templateBuffer = Buffer.from(input.templateBuffer);
|
||||
|
||||
const output = await applyTemplate(
|
||||
templateBuffer,
|
||||
input.templateData,
|
||||
input.secret,
|
||||
input.privateKeyHex,
|
||||
input.ticketSec
|
||||
);
|
||||
|
||||
return Buffer.from(output);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue