feat(api): add endpoint to get all non-hidden stories a user has written
This commit is contained in:
		
							parent
							
								
									79f5f2cc10
								
							
						
					
					
						commit
						8bf78a0494
					
				
							
								
								
									
										11
									
								
								server/api/user/[id]/stories.get.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								server/api/user/[id]/stories.get.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
			
		||||
import listQuerier from "~/lib/server/dbHelpers/listQuerier";
 | 
			
		||||
 | 
			
		||||
export default cachedEventHandler(async (ev) => {
 | 
			
		||||
	const id = parseInt(getRouterParam(ev, "id")!);
 | 
			
		||||
	let s = await listQuerier({ author: { $in: [id] } }, ev.context);
 | 
			
		||||
	const t = s.map((a) => a.toObject());
 | 
			
		||||
	return {
 | 
			
		||||
		stories: t,
 | 
			
		||||
		total: t.length,
 | 
			
		||||
	};
 | 
			
		||||
});
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user