refactor(*): rename route
change "bands" to "band" BREAKING CHANGE: breaks anything that tries to access `/api/bands/*`
This commit is contained in:
		
							parent
							
								
									b0a69d5d56
								
							
						
					
					
						commit
						ee7ea24e4e
					
				| @ -22,7 +22,7 @@ | |||||||
| 		data: FormChapter; | 		data: FormChapter; | ||||||
| 	}>(); | 	}>(); | ||||||
| 	let acData = toRef(data); | 	let acData = toRef(data); | ||||||
| 	let { data: _bands } = await useApiFetch("/bands/all"); | 	let { data: _bands } = await useApiFetch("/band/all"); | ||||||
| 	let bands = ref(_bands); | 	let bands = ref(_bands); | ||||||
| 	provide("curName", name + "."); | 	provide("curName", name + "."); | ||||||
| 	provide("bandlist", bands); | 	provide("bandlist", bands); | ||||||
|  | |||||||
| @ -2,10 +2,9 @@ | |||||||
| 	import storyList from "~/components/listings/stories.vue"; | 	import storyList from "~/components/listings/stories.vue"; | ||||||
| 	import { IBand } from "~/models/band"; | 	import { IBand } from "~/models/band"; | ||||||
| 	const route = useRoute(); | 	const route = useRoute(); | ||||||
| 	const { data: band } = await useApiFetch<IBand>(`/bands/${route.params.id}`); | 	const { data: band } = await useApiFetch<IBand>(`/band/${route.params.id}`); | ||||||
| 	const pref = `/bands/${route.params.id}/stories`; |  | ||||||
| </script> | </script> | ||||||
| <template> | <template> | ||||||
| 	<a-typography-title> Browsing {{ band?.name }} fiction </a-typography-title> | 	<a-typography-title> Browsing {{ band?.name }} fiction </a-typography-title> | ||||||
| 	<story-list :prefix="pref" /> | 	<story-list :prefix="`/band/${route.params.id}/stories`" /> | ||||||
| </template> | </template> | ||||||
|  | |||||||
| @ -1,8 +1,16 @@ | |||||||
|  | import { messages } from "~/lib/server/constants"; | ||||||
| import { Band } from "~/models/band"; | import { Band } from "~/models/band"; | ||||||
| 
 | 
 | ||||||
| export default eventHandler(async (ev) => { | export default eventHandler(async (ev) => { | ||||||
| 	const id = parseInt(getRouterParam(ev, "id") as string); | 	const id = parseInt(getRouterParam(ev, "id") as string); | ||||||
| 	const band = await Band.findById(id).exec(); | 	const band = await Band.findById(id).exec(); | ||||||
| 
 | 
 | ||||||
| 	return band; | 	if (!band) { | ||||||
|  | 		throw createError({ | ||||||
|  | 			statusCode: 404, | ||||||
|  | 			message: messages[404], | ||||||
|  | 		}); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return band.toObject(); | ||||||
| }); | }); | ||||||
| @ -18,10 +18,11 @@ export default eventHandler(async (event) => { | |||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 		event.context, | 		event.context, | ||||||
|  | 		event, | ||||||
|  | 		25, | ||||||
| 	); /*  */ | 	); /*  */ | ||||||
| 	return { | 	return { | ||||||
| 		...band.toObject(), | 		...band.toObject(), | ||||||
| 		stories: stories /* .slice(skipAmt, skipAmt + 20 + 1) */, | 		...stories, | ||||||
| 		total: stories.length, |  | ||||||
| 	}; | 	}; | ||||||
| }); | }); | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user