2025-07-16 18:59:35 +01:00
|
|
|
var express = require("express");
|
2022-02-06 21:47:53 -05:00
|
|
|
var router = express.Router();
|
2025-07-16 18:59:35 +01:00
|
|
|
const QRCode = require("qrcode");
|
2022-02-06 21:47:53 -05:00
|
|
|
|
|
|
|
|
/* GET home page. */
|
2025-07-16 18:59:35 +01:00
|
|
|
router.get("/", function (req, res, next) {
|
|
|
|
|
res.render("index", { title: "Express" });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
router.get("/code", async function (req, res, next) {
|
|
|
|
|
const code = Math.random().toString(36).substring(2, 8); // random code
|
|
|
|
|
const qrUrl = `/api/v1/code/${code}?amount=1&service=software%20service`;
|
|
|
|
|
const qrData = await QRCode.toDataURL(
|
|
|
|
|
`http://localhost:${process.env.PORT || 3000}${qrUrl}`
|
|
|
|
|
);
|
|
|
|
|
res.render("code", {
|
|
|
|
|
qrData,
|
|
|
|
|
qrUrl: `http://localhost:${process.env.PORT || 3000}${qrUrl}`,
|
|
|
|
|
});
|
2022-02-06 21:47:53 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
module.exports = router;
|