ryu-js / plugins /gempa.js
randydev's picture
Update plugins/gempa.js
168994a verified
raw
history blame
919 Bytes
import express from 'express';
import { GempaBumi } from '../lib/scrapper.js';
import { authenticateApiKey, apiLimiter } from '../middleware/midware.js';
const GempaRoutes = express.Router();
/**
* @swagger
* /api/v1/gempa-bumi:
* get:
* summary: gempa bumi Random
* - in: header
* name: x-api-key
* required: true
* description: API key for authentication
* schema:
* type: string
* responses:
* 200:
* description: Success
*/
GempaRoutes.get('/api/v1/gempa-bumi', authenticateApiKey, apiLimiter, async (req, res) => {
try {
const result = await GempaBumi();
if (result) {
res.json({ result });
} else {
res.status(404).json({ error: "No result found." });
}
} catch (error) {
res.status(500).json({ error: error.message });
}
});
export { GempaRoutes };