Fixed the controller not waiting for initialization

ref #5
This commit is contained in:
2021-02-06 21:37:56 +01:00
parent 47a05facb3
commit ee8ba99cc7
2 changed files with 10 additions and 3 deletions

View File

@@ -11,10 +11,15 @@ import { PdfCreator } from '../PdfCreator';
@JsonController()
export class PdfController {
private pdf: PdfCreator = new PdfCreator();
private initialized: boolean = false;
@Post('/contracts')
@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) {
if (!this.initialized) {
await this.pdf.init();
this.initialized = true;
}
if (!Array.isArray(runners)) {
runners = [runners];
}