feat(api): add dedicated route to fetch user's own stories
This commit is contained in:
parent
f86f46eb50
commit
c795e5d293
11
server/api/user/me/stories.get.ts
Normal file
11
server/api/user/me/stories.get.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { listQuerier } from "@server/dbHelpers";
|
||||||
|
import { isLoggedIn } from "@server/middlewareButNotReally";
|
||||||
|
export default cachedEventHandler(async (ev) => {
|
||||||
|
isLoggedIn(ev);
|
||||||
|
const id = ev.context.currentUser!._id;
|
||||||
|
let s = await listQuerier({ author: id }, ev.context, ev);
|
||||||
|
return {
|
||||||
|
stories: s.stories,
|
||||||
|
total: s.stories.length,
|
||||||
|
};
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user