20 lines
496 B
TypeScript
20 lines
496 B
TypeScript
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: { $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`;
|
|
},
|
|
},
|
|
);
|