@@ -1,6 +1,7 @@
 | 
			
		||||
import { Body, JsonController, Post, QueryParam, Res } from 'routing-controllers';
 | 
			
		||||
import { OpenAPI } from 'routing-controllers-openapi';
 | 
			
		||||
import { Runner } from '../models/Runner';
 | 
			
		||||
import { RunnerCard } from '../models/RunnerCard';
 | 
			
		||||
import { PdfCreator } from '../PdfCreator';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -27,4 +28,19 @@ export class PdfController {
 | 
			
		||||
        res.setHeader('content-type', 'application/pdf');
 | 
			
		||||
        return contracts;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @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) {
 | 
			
		||||
        if (!this.initialized) {
 | 
			
		||||
            await this.pdf.init();
 | 
			
		||||
            this.initialized = true;
 | 
			
		||||
        }
 | 
			
		||||
        if (!Array.isArray(cards)) {
 | 
			
		||||
            cards = [cards];
 | 
			
		||||
        }
 | 
			
		||||
        const contracts = await this.pdf.generateRunnerCards(cards, locale);
 | 
			
		||||
        res.setHeader('content-type', 'application/pdf');
 | 
			
		||||
        return contracts;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user