import { argsToBools, limitToInt, normalizeUrlQuery } from "./timeline.js"; import { SearchHelpers } from "../helpers/search.js"; import { auth } from "../middleware/auth.js"; export function setupEndpointsSearch(router) { router.get([ "/v1/search", "/v2/search" ], auth(true, [ 'read:search' ]), async (ctx)=>{ const args = normalizeUrlQuery(argsToBools(limitToInt(ctx.query), [ 'resolve', 'following', 'exclude_unreviewed' ])); ctx.body = await SearchHelpers.search(args.q, args.type, args.resolve, args.following, args.account_id, args['exclude_unreviewed'], args.max_id, args.min_id, args.limit, args.offset, ctx); if (ctx.path === "/v1/search") { ctx.body = { ...ctx.body, hashtags: ctx.body.hashtags.map((p)=>p.name) }; } }); }