parent
47a05facb3
commit
ee8ba99cc7
@ -20,11 +20,13 @@ export class PdfCreator {
|
|||||||
* Initializes i18n(ext), Handlebars and puppeteer.
|
* Initializes i18n(ext), Handlebars and puppeteer.
|
||||||
*/
|
*/
|
||||||
constructor() {
|
constructor() {
|
||||||
this.init().then(() => {
|
this.init();
|
||||||
return this;
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main constructor.
|
||||||
|
* Initializes i18n(ext), Handlebars and puppeteer.
|
||||||
|
*/
|
||||||
public async init() {
|
public async init() {
|
||||||
await i18next
|
await i18next
|
||||||
.use(Backend)
|
.use(Backend)
|
||||||
|
@ -11,10 +11,15 @@ import { PdfCreator } from '../PdfCreator';
|
|||||||
@JsonController()
|
@JsonController()
|
||||||
export class PdfController {
|
export class PdfController {
|
||||||
private pdf: PdfCreator = new PdfCreator();
|
private pdf: PdfCreator = new PdfCreator();
|
||||||
|
private initialized: boolean = false;
|
||||||
|
|
||||||
@Post('/contracts')
|
@Post('/contracts')
|
||||||
@OpenAPI({ description: "Generate Sponsoring contract pdfs from runner objects.<br>You can choose your prefered locale by passing the 'locale' query-param." })
|
@OpenAPI({ description: "Generate Sponsoring contract pdfs from runner objects.<br>You can choose your prefered locale by passing the 'locale' query-param." })
|
||||||
async generateContracts(@Body({ validate: true }) runners: Runner | Runner[], @Res() res: any, @QueryParam("locale") locale: string) {
|
async generateContracts(@Body({ validate: true }) runners: Runner | Runner[], @Res() res: any, @QueryParam("locale") locale: string) {
|
||||||
|
if (!this.initialized) {
|
||||||
|
await this.pdf.init();
|
||||||
|
this.initialized = true;
|
||||||
|
}
|
||||||
if (!Array.isArray(runners)) {
|
if (!Array.isArray(runners)) {
|
||||||
runners = [runners];
|
runners = [runners];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user