Merge branch 'dev' into feature/14-card_generation
This commit is contained in:
commit
b77945a9e4
9 files changed
+261
-106
No files matched your search
@@ -2,8 +2,36 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. Dates are displayed in UTC.
|
||||
|
||||
#### [v0.1.3](https://git.odit.services/lfk/document-server/compare/v0.1.2...v0.1.3)
|
||||
|
||||
- Merge pull request 'Barcode generation feature/13-barcode_generation' (#21) from feature/13-barcode_generation into dev [`ff36b48`](https://git.odit.services/lfk/document-server/commit/ff36b4871f2d696c0b86883d529365ee8f1c6132)
|
||||
- 🚀Bumped version to v0.1.3 [`6a14232`](https://git.odit.services/lfk/document-server/commit/6a142328898d5b89fa11eaf033372971d1093b0c)
|
||||
- 🧾New changelog file version [CI SKIP] [skip ci] [`ad9a8a4`](https://git.odit.services/lfk/document-server/commit/ad9a8a4fe0649d48db924771be8ecb4cbf5c162a)
|
||||
- Implemented async barcode generation using async helpers [`edc846a`](https://git.odit.services/lfk/document-server/commit/edc846ab05319a4e60422625678f204bc145884c)
|
||||
- Reworked template layout for barcode [`1c06689`](https://git.odit.services/lfk/document-server/commit/1c066898009883f510fa204c66800e5f6228a15d)
|
||||
- Added basic barcode generation [`8072d0b`](https://git.odit.services/lfk/document-server/commit/8072d0b1940ef6f316ce78dcbcb9e5af5bab04e7)
|
||||
- 🧾New changelog file version [CI SKIP] [skip ci] [`03f63e3`](https://git.odit.services/lfk/document-server/commit/03f63e3777381a4475910e6fa4a3986f87b73f39)
|
||||
- Merge pull request 'Alpha Release 0.1.3 - More env vars' (#20) from dev into main [`ecd02a1`](https://git.odit.services/lfk/document-server/commit/ecd02a1af7431d0bf615c4ec064f64e023946e49)
|
||||
- Now with working code scaleing [`4b79b29`](https://git.odit.services/lfk/document-server/commit/4b79b29ee6319559c9d68ddb11f831d25f12b3da)
|
||||
- Now loading barcode format from env with overwrite via query param [`9a7c1d6`](https://git.odit.services/lfk/document-server/commit/9a7c1d64fdbdadbd104739133a87773e4d2bca01)
|
||||
- Added fallback error image [`5023457`](https://git.odit.services/lfk/document-server/commit/502345782f26895ccf3089d15c3817709b62dfcc)
|
||||
- First part of the handlebars barcode generation [`a35f8cf`](https://git.odit.services/lfk/document-server/commit/a35f8cfd3aa94923968fd77425c074844d28ec0d)
|
||||
- 🧾New changelog file version [CI SKIP] [skip ci] [`b6296b8`](https://git.odit.services/lfk/document-server/commit/b6296b8d97cda943dfb5e11bc9dfbb2f363f5b81)
|
||||
- Added todo [`75d2ac3`](https://git.odit.services/lfk/document-server/commit/75d2ac3c5f80f8440b6d48c33b15ef17565559b3)
|
||||
- Removed promise [`e1ec193`](https://git.odit.services/lfk/document-server/commit/e1ec193a4ff1cd618da90f5f2d029ec848a6f669)
|
||||
- Added new env vars to config [`3bb322e`](https://git.odit.services/lfk/document-server/commit/3bb322ede5db15a147c0d7a8db2a68ccb7fa2112)
|
||||
- Now loading interpolation vars from config/env [`b4ebae2`](https://git.odit.services/lfk/document-server/commit/b4ebae283b472b2f0c6e28caed49b30edb119585)
|
||||
- Fixed broken mime-type [`4187a8e`](https://git.odit.services/lfk/document-server/commit/4187a8e82015495c0e0362e957e236ed6935a908)
|
||||
- Merge pull request 'Load more stuff from env feature/16-env_vars' (#17) from feature/16-env_vars into dev [`bc4d16e`](https://git.odit.services/lfk/document-server/commit/bc4d16e6f8959ed35d7e87647de84584cdfddd7b)
|
||||
- Added new env vars to readme [`b77bb3a`](https://git.odit.services/lfk/document-server/commit/b77bb3ad9dba9d73c2c81215ba57936192155a9a)
|
||||
- Switched to using the current runner's id as the barcode text [`3e2b011`](https://git.odit.services/lfk/document-server/commit/3e2b011d2887d261fb9c36820982095d6dd6d847)
|
||||
- Added barcode field to template [`27d1d69`](https://git.odit.services/lfk/document-server/commit/27d1d69360c8513079abcfe3a6fc2a50309a2b61)
|
||||
- 🧾New changelog file version [CI SKIP] [skip ci] [`a306009`](https://git.odit.services/lfk/document-server/commit/a30600943d01116b99e946cb705a16d0372b5095)
|
||||
|
||||
#### [v0.1.2](https://git.odit.services/lfk/document-server/compare/v0.1.1...v0.1.2)
|
||||
|
||||
> 7 February 2021
|
||||
|
||||
- Merge pull request 'Alpha Release 0.1.2 - Hotfix release' (#15) from dev into main [`123cf8a`](https://git.odit.services/lfk/document-server/commit/123cf8ad48a45fa10dcd5208215a6e525f31115a)
|
||||
- 🧾New changelog file version [CI SKIP] [skip ci] [`22b1e00`](https://git.odit.services/lfk/document-server/commit/22b1e0097efc865de9cc150cb0d0b99bf789b519)
|
||||
- 🚀Bumped version to v0.1.2 [`7e507d4`](https://git.odit.services/lfk/document-server/commit/7e507d4cc415877ac0b25503dc0ff9ecdceabf42)
|
||||
|
||||
@@ -1,75 +1,78 @@
|
||||
# @lfk/document-server
|
||||
|
||||
The document generation server responsible for creating pdfs for sponsoring contracts, certificates and more.
|
||||
This server doesn't interact with any database and can therefor be deployed on it's own.
|
||||
The basic generation mechanism makes the templates and routes interchangeable (if you want to expand or modify it).
|
||||
|
||||
## Quickstart 🐳
|
||||
> Use this to run the document server in docker.
|
||||
|
||||
1. Clone the repo or copy the docker-compose
|
||||
2. Run in the folder that contains the docker-compose file: `docker-compose up -d`
|
||||
3. Visit http://127.0.0.1:4010/docs to check if the server is running
|
||||
|
||||
## Dev Setup 🛠
|
||||
> Local dev setup
|
||||
|
||||
1. Rename the .env.example file to .env (you can adjust app port and other settings, if needed)
|
||||
2. Install Dependencies
|
||||
```bash
|
||||
yarn
|
||||
```
|
||||
3. Start the server
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
## ENV Vars
|
||||
> You can provide them via .env file or docker env vars.
|
||||
|
||||
| Name | Type | Default | Description
|
||||
| - | - | - | -
|
||||
| APP_PORT | Number | 4010 | The port the backend server listens on. Is optional.
|
||||
| NODE_ENV | String | dev | The apps env - influences debug info.
|
||||
|
||||
## Templates
|
||||
> The document server uses html templates to generate various pdf documents.
|
||||
> The templates are stored in src/templates by default.
|
||||
|
||||
We provide a set of default templates that we use for the ["Lauf für Kaya!" charity run](https://lauf-fuer-kaya.de).
|
||||
We use handlebars for templateing utilizing i18next for translation - the i18n string format in the templates is : `{{__ "string"}}`
|
||||
You can provide your own templates by replacing the ones we provided before compiling the project or by simply mounting your custom templates into the docker container.
|
||||
|
||||
The server currently needs the following templates to work:
|
||||
* sponsoring_contract.html
|
||||
|
||||
### Sponsoring Contracts
|
||||
|
||||
| Template Data | Type | Optional | Description
|
||||
| - | - | - | -
|
||||
| runners | array(Runner) | ❌ | The runner objects. We generate a contract for each runner on a new DIN-A5 page.
|
||||
|
||||
|
||||
## Recommended Editor
|
||||
|
||||
[Visual Studio Code](https://code.visualstudio.com/)
|
||||
|
||||
### Recommended Extensions
|
||||
|
||||
* will be automatically recommended via ./vscode/extensions.json
|
||||
* we also provide a config for i18n-ally in the .vscode folder
|
||||
|
||||
## Staging
|
||||
### Branches & Tags
|
||||
* vX.Y.Z: Release tags created from the main branch
|
||||
* The version numbers follow the semver standard
|
||||
* A new release tag automaticly triggers the release ci pipeline
|
||||
* main: Protected "release" branch
|
||||
* The latest tag of the docker image get's build from this
|
||||
* New releases get created as tags from this
|
||||
* dev: Current dev branch for merging the different feature branches and bugfixes
|
||||
* The dev tag of the docker image get's build from this
|
||||
* Only push minor changes to this branch!
|
||||
* To merge a feature branch into this please create a pull request
|
||||
* feature/xyz: Feature branches - nameing scheme: `feature/issueid-title`
|
||||
# @lfk/document-server
|
||||
|
||||
The document generation server responsible for creating pdfs for sponsoring contracts, certificates and more.
|
||||
This server doesn't interact with any database and can therefor be deployed on it's own.
|
||||
The basic generation mechanism makes the templates and routes interchangeable (if you want to expand or modify it).
|
||||
|
||||
## Quickstart 🐳
|
||||
> Use this to run the document server in docker.
|
||||
|
||||
1. Clone the repo or copy the docker-compose
|
||||
2. Run in the folder that contains the docker-compose file: `docker-compose up -d`
|
||||
3. Visit http://127.0.0.1:4010/docs to check if the server is running
|
||||
|
||||
## Dev Setup 🛠
|
||||
> Local dev setup
|
||||
|
||||
1. Rename the .env.example file to .env (you can adjust app port and other settings, if needed)
|
||||
2. Install Dependencies
|
||||
```bash
|
||||
yarn
|
||||
```
|
||||
3. Start the server
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
## ENV Vars
|
||||
> You can provide them via .env file or docker env vars.
|
||||
|
||||
| Name | Type | Default | Description
|
||||
| - | - | - | -
|
||||
| APP_PORT | Number | 4010 | The port the backend server listens on. Is optional.
|
||||
| NODE_ENV | String | dev | The apps env - influences debug info.
|
||||
| EVENT_NAME | String | "Please set the event name" | The event's name - used to generate pdf text.
|
||||
| CURRENCY_SYMBOL | String | "€" | The your currency's symbol - used to generate pdf text.
|
||||
| SPONSORING_RECEIPT_MINIMUM_AMOUNT | String | "10" | The mimimum total donation amount a sponsor has to donate to be able to receive a donation receipt - used to generate pdf text.
|
||||
|
||||
## Templates
|
||||
> The document server uses html templates to generate various pdf documents.
|
||||
> The templates are stored in src/templates by default.
|
||||
|
||||
We provide a set of default templates that we use for the ["Lauf für Kaya!" charity run](https://lauf-fuer-kaya.de).
|
||||
We use handlebars for templateing utilizing i18next for translation - the i18n string format in the templates is : `{{__ "string"}}`
|
||||
You can provide your own templates by replacing the ones we provided before compiling the project or by simply mounting your custom templates into the docker container.
|
||||
|
||||
The server currently needs the following templates to work:
|
||||
* sponsoring_contract.html
|
||||
|
||||
### Sponsoring Contracts
|
||||
|
||||
| Template Data | Type | Optional | Description
|
||||
| - | - | - | -
|
||||
| runners | array(Runner) | ❌ | The runner objects. We generate a contract for each runner on a new DIN-A5 page.
|
||||
|
||||
|
||||
## Recommended Editor
|
||||
|
||||
[Visual Studio Code](https://code.visualstudio.com/)
|
||||
|
||||
### Recommended Extensions
|
||||
|
||||
* will be automatically recommended via ./vscode/extensions.json
|
||||
* we also provide a config for i18n-ally in the .vscode folder
|
||||
|
||||
## Staging
|
||||
### Branches & Tags
|
||||
* vX.Y.Z: Release tags created from the main branch
|
||||
* The version numbers follow the semver standard
|
||||
* A new release tag automaticly triggers the release ci pipeline
|
||||
* main: Protected "release" branch
|
||||
* The latest tag of the docker image get's build from this
|
||||
* New releases get created as tags from this
|
||||
* dev: Current dev branch for merging the different feature branches and bugfixes
|
||||
* The dev tag of the docker image get's build from this
|
||||
* Only push minor changes to this branch!
|
||||
* To merge a feature branch into this please create a pull request
|
||||
* feature/xyz: Feature branches - nameing scheme: `feature/issueid-title`
|
||||
* bugfix/xyz: Branches for bugfixes - nameing scheme:`bugfix/issueid-title`
|
||||
+61
@@ -27,6 +27,35 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
# async-helpers
|
||||
**Author**: Brian Woodward (https://github.com/doowb)
|
||||
**Repo**: doowb/async-helpers
|
||||
**License**: MIT
|
||||
**Description**: Use async helpers in templates with engines that typically only handle sync helpers. Handlebars and Lodash have been tested.
|
||||
## License Text
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-2017, Brian Woodward.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
# axios
|
||||
**Author**: Matt Zabriskie
|
||||
**Repo**: [object Object]
|
||||
@@ -54,6 +83,38 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
# bwip-js
|
||||
**Author**: Mark Warren <mwarren@metafloor.com>
|
||||
**Repo**: [object Object]
|
||||
**License**: MIT
|
||||
**Description**: JavaScript barcode generator supporting over 100 types and standards.
|
||||
## License Text
|
||||
bwip-js : Barcode Writer in Pure JavaScript
|
||||
|
||||
Copyright (c) 2011-2019 Mark Warren
|
||||
|
||||
The MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
|
||||
# cheerio
|
||||
**Author**: Matt Mueller <mattmuelle@gmail.com> (mat.io)
|
||||
**Repo**: [object Object]
|
||||
|
||||
+3
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@odit/lfk-document-server",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"description": "The document generation server for the LfK! runner system. This generates certificates, sponsoring aggreements and more",
|
||||
"main": "src/app.ts",
|
||||
"scripts": {
|
||||
@@ -40,7 +40,9 @@
|
||||
"license": "CC-BY-NC-SA-4.0",
|
||||
"dependencies": {
|
||||
"@odit/class-validator-jsonschema": "^2.1.1",
|
||||
"async-helpers": "^0.3.17",
|
||||
"axios": "^0.21.1",
|
||||
"bwip-js": "^2.0.12",
|
||||
"cheerio": "^1.0.0-rc.5",
|
||||
"class-transformer": "0.3.1",
|
||||
"class-validator": "^0.13.1",
|
||||
|
||||
+12
-4
@@ -8,9 +8,12 @@ import mime from "mime-types";
|
||||
import path from 'path';
|
||||
import { PDFDocument } from 'pdf-lib';
|
||||
import puppeteer from "puppeteer";
|
||||
import { awaitAsyncHandlebarHelpers, helpers } from './asyncHelpers';
|
||||
import { config } from './config';
|
||||
import { Runner } from './models/Runner';
|
||||
import { RunnerCard } from './models/RunnerCard';
|
||||
import { RunnerGroup } from './models/RunnerGroup';
|
||||
|
||||
/**
|
||||
* This class is responsible for all things pdf creation.
|
||||
* This uses the html templates from src/templates.
|
||||
@@ -18,7 +21,7 @@ import { RunnerGroup } from './models/RunnerGroup';
|
||||
export class PdfCreator {
|
||||
private templateDir = path.join(__dirname, '/templates');
|
||||
private browser;
|
||||
private static interpolations = { eventname: "Lauf für Kaya! 2021", sponsoring_receipt_minimum_amount: '10', currency_symbol: "€" }
|
||||
private static interpolations = { eventname: config.eventname, sponsoring_receipt_minimum_amount: config.sponsoring_receipt_minimum_amount, currency_symbol: config.currency_symbol }
|
||||
|
||||
/**
|
||||
* Main constructor.
|
||||
@@ -68,7 +71,6 @@ export class PdfCreator {
|
||||
'--use-gl=swiftshader',
|
||||
'--no-sandbox'
|
||||
];
|
||||
|
||||
await i18next
|
||||
.use(Backend)
|
||||
.init({
|
||||
@@ -78,6 +80,8 @@ export class PdfCreator {
|
||||
loadPath: path.join(__dirname, '/locales/{{lng}}.json')
|
||||
}
|
||||
});
|
||||
|
||||
await Handlebars.registerHelper(helpers);
|
||||
await Handlebars.registerHelper('__',
|
||||
function (str) {
|
||||
return i18next.t(str, PdfCreator.interpolations).toString();
|
||||
@@ -91,7 +95,7 @@ export class PdfCreator {
|
||||
* @param runner The runner you want to generate the contracts for.
|
||||
* @param locale The locale used for the contracts (default:en)
|
||||
*/
|
||||
public async generateSponsoringContract(runners: Runner[], locale: string = "en"): Promise<Buffer> {
|
||||
public async generateSponsoringContract(runners: Runner[], locale: string = "en", codeformat: string = config.codeformat): Promise<Buffer> {
|
||||
if (runners.length == 1 && Object.keys(runners[0]).length == 0) {
|
||||
runners[0] = this.generateEmptyRunner();
|
||||
}
|
||||
@@ -108,7 +112,8 @@ export class PdfCreator {
|
||||
await i18next.changeLanguage(locale);
|
||||
const template_source = fs.readFileSync(`${this.templateDir}/sponsoring_contract.html`, 'utf8');
|
||||
const template = Handlebars.compile(template_source);
|
||||
const result = template({ runners })
|
||||
let result = template({ runners, codeformat });
|
||||
result = await awaitAsyncHandlebarHelpers(result);
|
||||
const pdf = await this.renderPdf(result, { format: "A5", landscape: true });
|
||||
return pdf
|
||||
}
|
||||
@@ -147,6 +152,9 @@ export class PdfCreator {
|
||||
const $ = cheerio.load(html)
|
||||
$('img').each(async (index, element) => {
|
||||
let imgsrc = $(element).attr("src");
|
||||
if (imgsrc.startsWith("data:image")) {
|
||||
return;
|
||||
}
|
||||
const img_type = mime.lookup(imgsrc);
|
||||
|
||||
if (!(img_type.includes("image"))) {
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import AsyncHelpers from "async-helpers";
|
||||
import bwipjs from "bwip-js";
|
||||
|
||||
export const asyncHelpers = new AsyncHelpers();
|
||||
async function generateBarcode(str, options, emtpy, cb) {
|
||||
let res = await generateBase64Barcode(options.toString(), str.toString());
|
||||
cb(null, res);
|
||||
}
|
||||
generateBarcode.async = true;
|
||||
asyncHelpers.set('--bc', generateBarcode);
|
||||
export const helpers = asyncHelpers.get({ wrap: true });
|
||||
|
||||
export async function generateBase64Barcode(type: string, content: string): Promise<String> {
|
||||
let options = {
|
||||
bcid: type,
|
||||
text: content,
|
||||
scale: 4,
|
||||
height: 10,
|
||||
width: 10,
|
||||
includetext: true,
|
||||
textxalign: 'center',
|
||||
}
|
||||
if (type != "qrcode") {
|
||||
delete options.width;
|
||||
}
|
||||
try {
|
||||
const barcode: Buffer = await bwipjs.toBuffer(options);
|
||||
return `data:image/png;base64,${barcode.toString('base64')}`;
|
||||
}
|
||||
catch {
|
||||
return errorimage;
|
||||
}
|
||||
}
|
||||
|
||||
export async function awaitAsyncHandlebarHelpers(input: string): Promise<string> {
|
||||
return await new Promise((resolve, reject) => {
|
||||
asyncHelpers.resolveIds(input, (err, data) => {
|
||||
if (err) { reject(err) }
|
||||
resolve(data)
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const errorimage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXkAAAFRCAMAAACmIi1UAAABS2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDIgNzkuMTYwOTI0LCAyMDE3LzA3LzEzLTAxOjA2OjM5ICAgICAgICAiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIi8+CiA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgo8P3hwYWNrZXQgZW5kPS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cLvnFwSBzRouSByr7Ca7eoK5+Gi75h9qwXFBDyRmNEGaFcIVZtW0P4ZLf0I2zUgDfecvQcUbrEWZVtGzAJX93Kdar+7z3gaHijIZ6g3vxhVmusidxyT+Mt/gU32wHzmhzZkrOoDDrX934egPHl7jkv3Fqd0ZnpOQM6g2+VSP1L9uGS/6DGmxn9Oah4IxGCLOCavQG5ctwyb/r1+GM3inzy
Line truncated
|
||||
+5
-1
@@ -4,7 +4,11 @@ configDotenv();
|
||||
export const config = {
|
||||
internal_port: parseInt(process.env.APP_PORT) || 4010,
|
||||
development: process.env.NODE_ENV === "production",
|
||||
version: process.env.VERSION || require('../package.json').version
|
||||
version: process.env.VERSION || require('../package.json').version,
|
||||
eventname: process.env.EVENT_NAME || "Please set the event name",
|
||||
currency_symbol: process.env.CURRENCY_SYMBOL || "€",
|
||||
sponsoring_receipt_minimum_amount: process.env.SPONSORING_RECEIPT_MINIMUM_AMOUNT || "10",
|
||||
codeformat: process.env.CODEFORMAT || "qrcode"
|
||||
}
|
||||
let errors = 0
|
||||
if (typeof config.internal_port !== "number") {
|
||||
|
||||
@@ -16,7 +16,7 @@ export class PdfController {
|
||||
|
||||
@Post('/contracts')
|
||||
@OpenAPI({ description: "Generate Sponsoring contract pdfs from runner objects.<br>You can choose your prefered locale by passing the 'locale' query-param.<br> If you provide more than 100 runenrs this could take a moment or two (we tested up to 1000 runners in about 70sec so far)." })
|
||||
async generateContracts(@Body({ validate: true, options: { limit: "500mb" } }) runners: Runner | Runner[], @Res() res: any, @QueryParam("locale") locale: string) {
|
||||
async generateContracts(@Body({ validate: true, options: { limit: "500mb" } }) runners: Runner | Runner[], @Res() res: any, @QueryParam("locale") locale: string, @QueryParam("codeformat") codeformat: string) {
|
||||
if (!this.initialized) {
|
||||
await this.pdf.init();
|
||||
this.initialized = true;
|
||||
@@ -24,7 +24,7 @@ export class PdfController {
|
||||
if (!Array.isArray(runners)) {
|
||||
runners = [runners];
|
||||
}
|
||||
const contracts = await this.pdf.generateSponsoringContract(runners, locale);
|
||||
const contracts = await this.pdf.generateSponsoringContract(runners, locale, codeformat);
|
||||
res.setHeader('content-type', 'application/pdf');
|
||||
return contracts;
|
||||
}
|
||||
|
||||
@@ -29,31 +29,36 @@
|
||||
<div class="sheet">
|
||||
<img id="header_img" width="100%" src="sponsoringheader.png" />
|
||||
<div style=" padding: 0 1rem 0 1rem;">
|
||||
<div class="columns" style="padding-bottom: 0;">
|
||||
<div class="column is-two-fifths">
|
||||
<p style="font-size: large; font-weight: bold;">{{__ "sponsoring_title"}}</p>
|
||||
</div>
|
||||
<div class="column">
|
||||
<p style="font-size: x-small; vertical-align: revert; margin-top: auto;">{{__ "please_use_blockletters"}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<p> {{__ "sponsoring_subtitle"}} </p>
|
||||
<div class="columns" style="padding-top: 0;">
|
||||
<div class="column is-8">
|
||||
<span style="border-bottom: 1px solid; width: 100%; display: block;">{{this.firstname}}
|
||||
{{this.middlename}}</span>
|
||||
<p style="font-size: x-small; display: block;">{{__ "firstname"}}</p>
|
||||
</div>
|
||||
<div class="column is-2">
|
||||
<span style="border-bottom: 1px solid; width: 100%; display: block;">{{this.id}}</span>
|
||||
<p style="font-size: x-small; display: block;">ID</p>
|
||||
</div>
|
||||
<div class="column">
|
||||
<!-- CODE Here -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="columns">
|
||||
<div class="column is-10">
|
||||
<div class="columns" style="padding-bottom: 0;">
|
||||
<div class="column is-two-fifths">
|
||||
<p style="font-size: large; font-weight: bold;">{{__ "sponsoring_title"}}</p>
|
||||
</div>
|
||||
<div class="column">
|
||||
<p style="font-size: x-small; vertical-align: revert; margin-top: auto;">{{__ "please_use_blockletters"}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<p> {{__ "sponsoring_subtitle"}} </p>
|
||||
<div class="columns">
|
||||
<div class="column is-9">
|
||||
<span style="border-bottom: 1px solid; width: 100%; display: block;">{{this.firstname}}
|
||||
{{this.middlename}}</span>
|
||||
<p style="font-size: x-small; display: block;">{{__ "firstname"}}</p>
|
||||
</div>
|
||||
<div class="column is-3">
|
||||
<span style="border-bottom: 1px solid; width: 100%; display: block;">{{this.id}}</span>
|
||||
<p style="font-size: x-small; display: block;">ID</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<img style="vertical-align: revert; margin-top: auto; object-fit: cover; max-height: 2cm;"
|
||||
src="{{--bc this.id ../codeformat}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="columns" style="padding-top: 1rem;">
|
||||
<div class="column is-6">
|
||||
<span style="border-bottom: 1px solid; width: 100%; display: block;">{{this.lastname}}</span>
|
||||
<p style="font-size: x-small; display: block;">{{__ "lastname"}}</p>
|
||||
|
||||
Reference in new issue
Block a user