2023-12-31 01:48:22 -05:00
|
|
|
import { listQuerier } from "@server/dbHelpers";
|
|
|
|
import { isLoggedIn } from "@server/middlewareButNotReally";
|
2024-03-16 20:58:39 -04:00
|
|
|
export default cachedEventHandler(
|
|
|
|
async (ev) => {
|
|
|
|
isLoggedIn(ev);
|
|
|
|
const id = ev.context.currentUser!._id;
|
|
|
|
let s = await listQuerier({ author: { $in: [id] } }, ev.context, ev);
|
|
|
|
return {
|
|
|
|
stories: s?.stories || [],
|
|
|
|
total: s?.stories.length || 0,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
{
|
|
|
|
varies: ["Cookie"],
|
|
|
|
getKey(event) {
|
|
|
|
return `${event.context.currentUser?._id || null}/stories`;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|