Skip to content

Commit 4e446b3

Browse files
authored
Refactor SVG card generation logic and error handling
1 parent 7366ef3 commit 4e446b3

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

api/github-card.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ app.get("/api/svg-card/", async (req, res) => {
8484

8585
if (typeNum == 1) {
8686

87-
const svg = await generateSVG(
87+
desc = `❝ ${desc} ❞`;
88+
desc = wrapSVGText(desc, 50, 17);
89+
90+
const svg = await generateSVGOne(
8891
avatarBase64,
8992
name,
9093
desc,
@@ -107,8 +110,9 @@ app.get("/api/svg-card/", async (req, res) => {
107110
res.send(svg);
108111

109112
} else if (typeNum == 2) {
110-
111-
const svg2 = await generateSVG2(
113+
114+
desc = wrapSVGTextCenter(desc, 600, 75, 40, 18);
115+
const svg2 = await generateSVGTwo(
112116
avatarBase64,
113117
name,
114118
desc
@@ -117,7 +121,7 @@ app.get("/api/svg-card/", async (req, res) => {
117121
res.setHeader("Content-Type", "image/svg+xml");
118122
res.send(svg2);
119123
} else {
120-
124+
121125
const errorSvg = generateErrorSVG(
122126
"Error, Type must be 1 or 2.\n",
123127
"The form cannot be processed before the type is filled in correctly.",
@@ -166,5 +170,6 @@ module.exports = app;
166170

167171

168172

173+
169174

170175

0 commit comments

Comments
 (0)