Alpha Release 0.3.3 - Download options #32

Merged
niggl merged 8 commits from dev into main 2021-02-19 19:09:28 +00:00
Showing only changes of commit 1ca5d3ea07 - Show all commits

View File

@ -37,7 +37,7 @@ export class PdfController {
@Post('/cards')
@OpenAPI({ description: "Generate runner card pdfs from runner card objects.<br>You can choose your prefered locale by passing the 'locale' query-param." })
async generateCards(@Body({ validate: true, options: { limit: "500mb" } }) cards: RunnerCard | RunnerCard[], @Res() res: any, @QueryParam("locale") locale: string) {
async generateCards(@Body({ validate: true, options: { limit: "500mb" } }) cards: RunnerCard | RunnerCard[], @Res() res: any, @QueryParam("locale") locale: string, @QueryParam("download") download: boolean) {
if (!this.initialized) {
await this.pdf.init();
this.initialized = true;
@ -48,6 +48,9 @@ export class PdfController {
cards = this.mapCardGroupNames(cards);
const contracts = await this.pdf.generateRunnerCards(cards, locale);
res.setHeader('content-type', 'application/pdf');
if (download) {
res.setHeader('Content-Disposition', 'attachment; filename="cards.pdf"')
}
return contracts;
}