UNPKG

rsshub

Version:
39 lines (37 loc) 1.17 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs"; import "./parse-date-BrP7mxXf.mjs"; import { n as parseLiterature, t as baseUrl } from "./utils-BOTDwh-v.mjs"; //#region lib/routes/inspirehep/literature.ts const route = { path: "/literature/:q", example: "/inspirehep/literature/Physics", parameters: { q: "Search keyword" }, name: "Literature Search", maintainers: ["TonyRL"], radar: [{ source: ["inspirehep.net/literature"], target: (_params, url) => `/inspirehep/literature/${new URL(url).searchParams.get("q")}` }], handler }; async function handler(ctx) { const q = ctx.req.param("q"); const limit = ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit")) : 25; const items = parseLiterature((await ofetch_default(`${baseUrl}/api/literature`, { query: { sort: "mostrecent", size: limit, page: 1, q } })).hits.hits); return { title: "Literature Search - INSPIRE", link: `${baseUrl}/literature?sort=mostrecent&size=${limit}&page=1&q=${q}`, item: items }; } //#endregion export { route };