refactor(api): add api route to retrieve full story information
with text
This commit is contained in:
		
							parent
							
								
									e13f9de5d3
								
							
						
					
					
						commit
						f1190af5df
					
				
							
								
								
									
										14
									
								
								server/api/story/[id]/full.get.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								server/api/story/[id]/full.get.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,14 @@ | |||||||
|  | import storyQuerier from "~/lib/server/dbHelpers/storyQuerier"; | ||||||
|  | import chapterTransformer from "~/lib/server/dbHelpers/chapterTransformer"; | ||||||
|  | import storyCheck from "~/lib/server/middlewareButNotReally/storyCheck"; | ||||||
|  | import isLoggedIn from "~/lib/server/middlewareButNotReally/isLoggedIn"; | ||||||
|  | 
 | ||||||
|  | export default eventHandler(async (ev) => { | ||||||
|  | 	isLoggedIn(ev); | ||||||
|  | 	const s = await storyQuerier(ev); | ||||||
|  | 	const story = s.toObject(); | ||||||
|  | 	for (let i = 0; i < story.chapters.length; i++) { | ||||||
|  | 		story.chapters[i] = await chapterTransformer(s, ev, i); | ||||||
|  | 	} | ||||||
|  | 	return story; | ||||||
|  | }); | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user