mirror of
https://github.com/aljazceru/ditto.git
synced 2025-12-25 17:24:25 +01:00
24 lines
616 B
TypeScript
24 lines
616 B
TypeScript
import { AppController } from '@/app.ts';
|
|
import { lookupAccount } from '../../utils.ts';
|
|
import { toAccount } from '../../transmute.ts';
|
|
|
|
const searchController: AppController = async (c) => {
|
|
const q = c.req.query('q');
|
|
|
|
if (!q) {
|
|
return c.json({ error: 'Missing `q` query parameter.' }, 422);
|
|
}
|
|
|
|
// For now, only support looking up accounts.
|
|
// TODO: Support searching statuses and hashtags.
|
|
const event = await lookupAccount(decodeURIComponent(q));
|
|
|
|
return c.json({
|
|
accounts: event ? [await toAccount(event)] : [],
|
|
statuses: [],
|
|
hashtags: [],
|
|
});
|
|
};
|
|
|
|
export { searchController };
|