import express from 'express'; | |
import { FontStyleCheckAPI } from '../lib/all.js'; | |
import { authenticateApiKey, apiLimiter } from '../middleware/midware.js'; | |
const FontsRoutes = express.Router(); | |
/** | |
* @swagger | |
* /api/v1/fonts-stylish/detected: | |
* get: | |
* summary: Fonts Styles | |
* tags: [Fonts] | |
* parameters: | |
* - in: query | |
* name: query | |
* required: true | |
* description: Font Stylish Text if checked detected | |
* schema: | |
* type: string | |
* - in: header | |
* name: x-api-key | |
* required: true | |
* description: API key for authentication | |
* schema: | |
* type: string | |
* responses: | |
* 200: | |
* description: Success | |
*/ | |
FontsRoutes.get('/api/v1/fonts-stylish/detected', authenticateApiKey, apiLimiter, async (req, res) => { | |
try { | |
const query = req.query.query | |
if (!query) { | |
return res.status(401).json({ error: "Invalid Query." }); | |
} | |
const results = await FontStyleCheckAPI(query); | |
if (results) { | |
res.json({ results }); | |
} else { | |
res.status(404).json({ error: "No result found." }); | |
} | |
} catch (error) { | |
res.status(500).json({ error: error.message }); | |
} | |
}); | |
export { FontsRoutes }; |