Update router/api.js
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
sora-ext 2025-02-24 15:12:46 +01:00
parent 8a46f473eb
commit 1e10109bbe

View File

@ -1,37 +1,23 @@
const axios = require("axios");
module.exports = (fastify, opts, done) => { module.exports = (fastify, opts, done) => {
fastify.get("/flight/:id", async (req, reply) => { fastify.get("/flight/:id", async (req, reply) => {
const ENDPOINT = "https://www.flightradar24.com/v1/search/web/find";
const FORMAT = "-";
if (req.params.id) { if (req.params.id) {
axios const url = new URL("https://www.flightradar24.com/v1/search/web/find");
.get(ENDPOINT, { url.searchParams.append('format', '-')
params: { url.searchParams.append('query', req.params.id)
format: FORMAT, url.searchParams.append('limit', 16)
query: req.params.id, url.searchParams.append('type', 'schedule')
limit: 16, fetch(url).then((res) => reply.send(res.data));
type: "schedule",
},
})
.then((res) => reply.send(res.data));
} else { } else {
return reply.send([]); return reply.send([]);
} }
return reply; return reply;
}); });
fastify.get("/place/:id", async (req, reply) => { fastify.get("/place/:id", async (req, reply) => {
const ENDPOINT = "https://nominatim.openstreetmap.org/";
const FORMAT = "jsonv2";
if (req.params.id) { if (req.params.id) {
axios const url = new URL("https://nominatim.openstreetmap.org/");
.get(ENDPOINT, { url.searchParams.append('format', 'jsonv2')
params: { url.searchParams.append('q', req.params.id)
format: FORMAT, fetch(url).then((res) => reply.send(res.data));
q: req.params.id,
},
})
.then((res) => reply.send(res.data));
} else { } else {
return reply.send([]); return reply.send([]);
} }