You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

16 lines
536 B

import { addFeed } from "#server/service/rss";
import { RssUrlUnsafeError } from "#server/utils/rss-url";
export default defineWrappedResponseHandler(async (event) => {
const user = await event.context.auth.requireUser();
const body = await readBody<{ feedUrl: string }>(event);
try {
const feed = await addFeed(user.id, body.feedUrl);
return R.success({ feed });
} catch (e) {
if (e instanceof RssUrlUnsafeError) {
throw createError({ statusCode: 400, statusMessage: e.message });
}
throw e;
}
});