Alpha Release 0.1.0 - Contract generation #11

Merged
niggl merged 52 commits from dev into main 2021-02-07 15:53:09 +00:00
2 changed files with 10 additions and 2 deletions
Showing only changes of commit cd51e78282 - Show all commits

View File

@ -3,6 +3,11 @@ import { OpenAPI } from 'routing-controllers-openapi';
import { Runner } from '../models/Runner';
import { PdfCreator } from '../PdfCreator';
/**
* The pdf controller handels all endpoints concerning pdf generation.
* It therefore is the hearth of the document-generation server's endpoints.
* All endpoints have to accept a locale query-param to support i18n.
*/
@JsonController()
export class PdfController {
private pdf: PdfCreator;
@ -11,10 +16,10 @@ export class PdfController {
}
@Post('/contracts')
@OpenAPI({ description: "Generate Sponsoring contract pdfs from runner objects." })
@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 (!Array.isArray(runners)) {
runners = [runners]
runners = [runners];
}
const contracts = await this.pdf.generateSponsoringContract(runners, locale);
res.setHeader('content-type', 'application/pdf');

View File

@ -2,6 +2,9 @@ import { Get, JsonController } from 'routing-controllers';
import { OpenAPI } from 'routing-controllers-openapi';
import { config } from '../config';
/**
* The statuscontroller provides simple endpoints concerning basic information about the server.
*/
@JsonController()
export class StatusController {
@Get('/version')