Create fontsstyle.js
Browse files- plugins/fontsstyle.js +47 -0
plugins/fontsstyle.js
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import express from 'express';
|
2 |
+
import { FontStyleCheckAPI } from '../lib/all.js';
|
3 |
+
import { authenticateApiKey, apiLimiter } from '../middleware/midware.js';
|
4 |
+
|
5 |
+
const FontsRoutes = express.Router();
|
6 |
+
|
7 |
+
/**
|
8 |
+
* @swagger
|
9 |
+
* /api/v1/fonts-stylish/detected:
|
10 |
+
* get:
|
11 |
+
* summary: Anime Random
|
12 |
+
* tags: [Anime]
|
13 |
+
* parameters:
|
14 |
+
* - in: query
|
15 |
+
* name: text
|
16 |
+
* required: true
|
17 |
+
* description: Font Stylish Text if checked detected
|
18 |
+
* schema:
|
19 |
+
* type: string
|
20 |
+
* - in: header
|
21 |
+
* name: x-api-key
|
22 |
+
* required: true
|
23 |
+
* description: API key for authentication
|
24 |
+
* schema:
|
25 |
+
* type: string
|
26 |
+
* responses:
|
27 |
+
* 200:
|
28 |
+
* description: Success
|
29 |
+
*/
|
30 |
+
FontsRoutes.get('/api/v1/fonts-stylish/detected', authenticateApiKey, apiLimiter, async (req, res) => {
|
31 |
+
try {
|
32 |
+
const query = req.query.query
|
33 |
+
if (!query) = {
|
34 |
+
return res.status(401).json({ error: "Invalid Query." });
|
35 |
+
}
|
36 |
+
const results = await FontStyleCheckAPI(text);
|
37 |
+
if (results) {
|
38 |
+
res.json({ results });
|
39 |
+
} else {
|
40 |
+
res.status(404).json({ error: "No result found." });
|
41 |
+
}
|
42 |
+
} catch (error) {
|
43 |
+
res.status(500).json({ error: error.message });
|
44 |
+
}
|
45 |
+
});
|
46 |
+
|
47 |
+
export { FontsRoutes };
|