Files
girlcockbsky/pkgs/app/src/routes/getProfileData.ts

23 lines
588 B
TypeScript
Raw Normal View History

/** @jsx jsx */
2024-10-11 16:02:11 +02:00
import { jsx } from 'hono/jsx';
import { Handler } from 'hono';
import { HTTPException } from 'hono/http-exception';
import { fetchProfile } from '../lib/fetchProfile';
export const getProfileData: Handler<
Env,
2024-10-11 16:02:11 +02:00
'/profile/:user/json' | '/https://bsky.app/profile/:user/json'
> = async (c) => {
const { user } = c.req.param();
2024-10-11 16:02:11 +02:00
const agent = c.get('Agent');
try {
var { data } = await fetchProfile(agent, { user });
} catch (e) {
throw new HTTPException(500, {
2024-10-11 16:02:11 +02:00
message: `Failed to fetch the profile!\n${e}`,
});
}
2024-10-11 16:02:11 +02:00
return c.json(data);
};