Added todo

ref #13
This commit is contained in:
Nicolai Ort 2021-02-08 09:47:28 +01:00
parent 3e2b011d28
commit 75d2ac3c5f

View File

@ -2,15 +2,18 @@ import axios from 'axios';
import bwipjs from "bwip-js"; import bwipjs from "bwip-js";
import cheerio from "cheerio"; import cheerio from "cheerio";
import fs from "fs"; import fs from "fs";
import Handlebars from 'handlebars'; import handlebars from 'handlebars';
import i18next from "i18next"; import i18next from "i18next";
import Backend from 'i18next-fs-backend'; import Backend from 'i18next-fs-backend';
import mime from "mime-types"; import mime from "mime-types";
import path from 'path'; import path from 'path';
import { PDFDocument } from 'pdf-lib'; import { PDFDocument } from 'pdf-lib';
import promisedHandlebars from "promised-handlebars";
import puppeteer from "puppeteer"; import puppeteer from "puppeteer";
import { Runner } from './models/Runner'; import { Runner } from './models/Runner';
import { RunnerGroup } from './models/RunnerGroup'; import { RunnerGroup } from './models/RunnerGroup';
const Handlebars = promisedHandlebars(handlebars);
/** /**
* This class is responsible for all things pdf creation. * This class is responsible for all things pdf creation.
* This uses the html templates from src/templates. * This uses the html templates from src/templates.
@ -68,7 +71,6 @@ export class PdfCreator {
'--use-gl=swiftshader', '--use-gl=swiftshader',
'--no-sandbox' '--no-sandbox'
]; ];
await i18next await i18next
.use(Backend) .use(Backend)
.init({ .init({
@ -85,7 +87,8 @@ export class PdfCreator {
); );
await Handlebars.registerHelper('--bc', await Handlebars.registerHelper('--bc',
function (str) { function (str) {
return "data:image"; //TODO: Fix the async behaviour
return PdfCreator.generateBarcode("code39", str.toString());
} }
); );
this.browser = await puppeteer.launch({ headless: true, args: minimal_args }); this.browser = await puppeteer.launch({ headless: true, args: minimal_args });