Delete plugins/brat.js
Browse files- plugins/brat.js +0 -61
plugins/brat.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
| 1 |
-
const axios = require('axios');
|
| 2 |
-
const FormData = require('form-data');
|
| 3 |
-
|
| 4 |
-
const handler = async (req, res) => {
|
| 5 |
-
try {
|
| 6 |
-
const { text } = req.query;
|
| 7 |
-
|
| 8 |
-
if (!text) {
|
| 9 |
-
return res.status(400).json({
|
| 10 |
-
success: false,
|
| 11 |
-
error: 'Missing required parameter: text'
|
| 12 |
-
});
|
| 13 |
-
}
|
| 14 |
-
|
| 15 |
-
const imageUrl = `https://api.siputzx.my.id/api/m/brat?text=${encodeURIComponent(text)}&isAnimated=false&delay=500`;
|
| 16 |
-
|
| 17 |
-
const imageResponse = await axios.get(imageUrl, {
|
| 18 |
-
responseType: 'arraybuffer'
|
| 19 |
-
});
|
| 20 |
-
|
| 21 |
-
const formData = new FormData();
|
| 22 |
-
formData.append('file', Buffer.from(imageResponse.data), {
|
| 23 |
-
filename: 'image.jpg',
|
| 24 |
-
contentType: imageResponse.headers['content-type'] || 'image/jpeg'
|
| 25 |
-
});
|
| 26 |
-
|
| 27 |
-
const uploadResponse = await axios.post(
|
| 28 |
-
'https://cdnme.idnet.my.id/upload',
|
| 29 |
-
formData,
|
| 30 |
-
{
|
| 31 |
-
headers: {
|
| 32 |
-
...formData.getHeaders()
|
| 33 |
-
}
|
| 34 |
-
}
|
| 35 |
-
);
|
| 36 |
-
|
| 37 |
-
res.json({
|
| 38 |
-
author: "Herza",
|
| 39 |
-
success: true,
|
| 40 |
-
url: uploadResponse.data.url
|
| 41 |
-
});
|
| 42 |
-
|
| 43 |
-
} catch (error) {
|
| 44 |
-
res.status(500).json({
|
| 45 |
-
success: false,
|
| 46 |
-
error: error.message
|
| 47 |
-
});
|
| 48 |
-
}
|
| 49 |
-
};
|
| 50 |
-
|
| 51 |
-
module.exports = {
|
| 52 |
-
name: 'Brat Image Generator',
|
| 53 |
-
description: 'Generate brat style image and upload to CDN',
|
| 54 |
-
type: 'GET',
|
| 55 |
-
routes: ['api/maker/bratgen'],
|
| 56 |
-
tags: ['tools', 'image', 'generator'],
|
| 57 |
-
parameters: ['text'],
|
| 58 |
-
enabled: true,
|
| 59 |
-
main: ['Maker'],
|
| 60 |
-
handler
|
| 61 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|