diff --git a/src/inc/routes/api.mjs b/src/inc/routes/api.mjs index 7ba6de9..1dfbe92 100644 --- a/src/inc/routes/api.mjs +++ b/src/inc/routes/api.mjs @@ -1,5 +1,6 @@ import router from "../router"; import sql from "../sql"; +import { parse } from "url"; import cfg from "../../../config.json"; import { mimes, queries } from "./inc/api"; @@ -77,6 +78,7 @@ router.get(/^\/api\/item\/[0-9]+$/, async (req, res) => { const data = rows[0].length > 0 ? { ...rows[0][0], ...{ thumb: `${cfg.main.url}/t/${rows[0][0].id}.png`, + srchost: parse(rows[0][0].src).hostname, next: rows[1].length ? rows[1][0].id : null, prev: rows[2].length ? rows[2][0].id : null, } diff --git a/src/inc/routes/inc/api.mjs b/src/inc/routes/inc/api.mjs index 78a561e..295e171 100644 --- a/src/inc/routes/inc/api.mjs +++ b/src/inc/routes/inc/api.mjs @@ -9,7 +9,7 @@ export const queries = { main: "select id, mime, size, username, userchannel, usernetwork, stamp, dest, src from items ", where: where => `${where?`where ${where}`:""} order by rand() limit 1` }, - item: "select id, mime, size, src, stamp, userchannel, username, usernetwork from items where id = ? limit 1;" + item: "select id, mime, dest, size, src, stamp, userchannel, username, usernetwork from items where id = ? limit 1;" + "select id from items where id = (select min(id) from items where id > ?);" + "select id from items where id = (select max(id) from items where id < ?)", p: (trend, order) => `select id, mime from items where id ${trend} ? order by id ${order} limit ?`,