Alexainc commited on
Commit ·
f319594
1
Parent(s): 0d90a81
sec commit
Browse files- .gitignore +2 -0
- app.js +22 -28
.gitignore
CHANGED
|
@@ -6,3 +6,5 @@ node_modules
|
|
| 6 |
*.webp
|
| 7 |
*.jpg
|
| 8 |
package-lock.json
|
|
|
|
|
|
|
|
|
| 6 |
*.webp
|
| 7 |
*.jpg
|
| 8 |
package-lock.json
|
| 9 |
+
test*
|
| 10 |
+
|
app.js
CHANGED
|
@@ -19,36 +19,30 @@ app.get('/', (req, res) => {
|
|
| 19 |
// API endpoint to generate quote sticker
|
| 20 |
app.post('/api/generate', async (req, res) => {
|
| 21 |
try {
|
| 22 |
-
const {
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
}
|
| 39 |
|
| 40 |
-
const buffer = await createImage(
|
| 41 |
-
firstName || 'User',
|
| 42 |
-
lastName || '',
|
| 43 |
-
customEmojiId || null,
|
| 44 |
-
message || '',
|
| 45 |
-
nameColorId || 0,
|
| 46 |
-
inputImageBuffer,
|
| 47 |
-
replySender || null,
|
| 48 |
-
replyMessage || null,
|
| 49 |
-
replySenderColor || 0,
|
| 50 |
-
entities || []
|
| 51 |
-
);
|
| 52 |
|
| 53 |
res.set('Content-Type', 'image/webp');
|
| 54 |
res.send(buffer);
|
|
|
|
| 19 |
// API endpoint to generate quote sticker
|
| 20 |
app.post('/api/generate', async (req, res) => {
|
| 21 |
try {
|
| 22 |
+
const { messages } = req.body;
|
| 23 |
+
|
| 24 |
+
// Normalize to array of messages
|
| 25 |
+
let msgList;
|
| 26 |
+
if (Array.isArray(messages)) {
|
| 27 |
+
msgList = messages;
|
| 28 |
+
} else {
|
| 29 |
+
msgList = [{
|
| 30 |
+
firstName: req.body.firstName || 'User',
|
| 31 |
+
lastName: req.body.lastName || '',
|
| 32 |
+
customemojiid: req.body.customEmojiId || null,
|
| 33 |
+
message: req.body.message || '',
|
| 34 |
+
nameColorId: req.body.nameColorId || 0,
|
| 35 |
+
inputImageBuffer: req.body.avatarBase64 ? Buffer.from(req.body.avatarBase64.split(',')[1], 'base64') : null,
|
| 36 |
+
replySender: req.body.replySender || null,
|
| 37 |
+
replyMessage: req.body.replyMessage || null,
|
| 38 |
+
replysendercolor: req.body.replySenderColor || 0,
|
| 39 |
+
entities: req.body.entities || [],
|
| 40 |
+
id: '1',
|
| 41 |
+
isAbsoluteLast: true
|
| 42 |
+
}];
|
| 43 |
}
|
| 44 |
|
| 45 |
+
const buffer = await createImage(msgList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
res.set('Content-Type', 'image/webp');
|
| 48 |
res.send(buffer);
|