diff --git a/README.md b/README.md
index 45f1965..4ae8a4e 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,19 @@
-
-
# upn-qr
-A public API for generating UPN-QR codes on the fly
-
https://upn-qr.gitapp.si
-
+## Local development
+
+**requirements:**
+
+* Docker
+* Docker-compose
+
+
+The local devserver is accessible via http://localhost:8080
+
+```bash
+docker-compose up
+```
+
+
diff --git a/docker-compose.yaml b/docker-compose.yaml
new file mode 100644
index 0000000..cd283d5
--- /dev/null
+++ b/docker-compose.yaml
@@ -0,0 +1,22 @@
+version: 3.8
+
+services:
+ image: node:14
+ build:
+ context: ./
+ dockerfile: Dockerfile
+ command: ["yarn", "run", "dev"]
+ environment:
+ ENV: development
+ NODE_ENV: development
+ volumes:
+ - ./src:/var/src
+ - /var/src/node_modules
+ ports:
+ - 8080:80
+ healthcheck:
+ test: ["CMD", "curl", "-sSG", "http://localhost/healthcheck"]
+ interval: 30s
+ timeout: 10s
+ retries: 3
+ start_period: 15s
diff --git a/src/index.js b/src/index.js
index eb262a3..2348916 100644
--- a/src/index.js
+++ b/src/index.js
@@ -45,12 +45,20 @@ app.get('/api/qrcode', async (req, res) => {
// SET DEFAULT PURPOSE_CODE
if (!req.query.purpose_code) req.query.purpose_code = "OTHR"
else {
- req.query.amount = String(req.query.amount).trim()
if (!String(req.query.purpose_code).match(/^[A-Z]{4}$/)) {
errors.push("purpose_code does not match the required format")
}
}
+ // DEADLINE is optional
+ if (req.query.deadline ) {
+ if(!String(req.query.deadline).match(/^[0-9]{2}\.[0-9]{2}\.[0-9]{4}$/)) {
+ errors.push("deadline does not match the required format")
+ }
+ } else {
+ req.query.deadline = ""
+ }
+
if (errors.length > 0) return res.status(400).send({
ok: false,
errors
@@ -69,7 +77,7 @@ ${req.query.amount}
${String(req.query.purpose_code).toUpperCase()}
${String(req.query.payment_purpose).toUpperCase()}
-
+${req.query.deadline}
${req.query.iban}
${req.query.reference}
${String(req.query.issuer_name).toUpperCase()}
diff --git a/src/views/form.ejs b/src/views/form.ejs
index 7c3676c..902ee73 100644
--- a/src/views/form.ejs
+++ b/src/views/form.ejs
@@ -72,10 +72,11 @@ div {
{ n: "issuer-address", d: "Issuer address", p: "Za deveto smreko 15 k", t: "text" },
{ n: "issuer-city", d: "Issuer city", p: "1000 Ljubljana", t: "text" },
{ n: "iban", d: "IBAN", p: "SI56047500000280672", t: "text" },
- { n: "amount", d: "Amount", p: "35090 (350.90€)", t: "number" },
+ { n: "amount", d: "Amount", p: "35090 (350.90€)", t: "number" },
{ n: "code", d: "Code", p: "OTHR", t: "text" },
{ n: "purpose", d: "Purpose", p: "moutain bike first half", t: "text" },
- { n: "reference", d: "Reference", p: "SI121234567890120", t: "text" }
+ { n: "reference", d: "Reference", p: "SI121234567890120", t: "text" },
+ { n: "deadline", d: "Deadline", p: "01.02.2034", t: "text" }
]
%>
<% for (const i of items) { %>
@@ -119,6 +120,7 @@ function getNewUrl () {
["issuer_name", val("issuer-name")],
["issuer_address", val("issuer-address")],
["issuer_city", val("issuer-city")],
+ ["deadline", val("deadline")]
].map(v => `${v[0]}=${v[1]}`).join("&")
return `${window.location.origin}/api/qrcode?${qstring}`
}
diff --git a/src/views/index.ejs b/src/views/index.ejs
index 8fb3987..77629b5 100644
--- a/src/views/index.ejs
+++ b/src/views/index.ejs
@@ -80,6 +80,10 @@ section div {
Purpose code
@@ -132,6 +136,7 @@ function getNewUrl () {
["issuer_name", val("issuer-name")],
["issuer_address", val("issuer-address")],
["issuer_city", val("issuer-city")],
+ ["deadline", val("deadline")],
].map(v => `${v[0]}=${v[1]}`).join("&")
return encodeURI(`${window.location.origin}/api/qrcode?${qstring}`)
}
@@ -201,9 +206,9 @@ updateQR()
<!-- Meant to be used as direct image source, for example -->
-<img src="https://upn-qr.gitapp.si/api/qrcode?client_name=Dobri človek&client_address=Kristanova ulica 1&client_city=1000 Ljubljana&amount=00000001000&payment_purpose=Donacija&iban=SI56021400015556761&reference=SI99&issuer_name=Slovenska Karitas&issuer_address=Kristanova ulica 1&issuer_city=1000 Ljubljana">
+<img src="https://upn-qr.gitapp.si/api/qrcode?client_name=Dobri človek&client_address=Kristanova ulica 1&client_city=1000 Ljubljana&amount=00000001000&deadline=01.02.2034&payment_purpose=Donacija&iban=SI56021400015556761&reference=SI99&issuer_name=Slovenska Karitas&issuer_address=Kristanova ulica 1&issuer_city=1000 Ljubljana">
-
+