29 lines
570 B
TypeScript
29 lines
570 B
TypeScript
|
|
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);
|
||
|
|
}
|