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
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C
5 changed files with 15 additions and 7 deletions

@ -22,7 +22,7 @@
data: FormChapter;
}>();
let acData = toRef(data);
let { data: _bands } = await useApiFetch("/bands/all");
let { data: _bands } = await useApiFetch("/band/all");
let bands = ref(_bands);
provide("curName", name + ".");
provide("bandlist", bands);

@ -2,10 +2,9 @@
import storyList from "~/components/listings/stories.vue";
import { IBand } from "~/models/band";
const route = useRoute();
const { data: band } = await useApiFetch<IBand>(`/bands/${route.params.id}`);
const pref = `/bands/${route.params.id}/stories`;
const { data: band } = await useApiFetch<IBand>(`/band/${route.params.id}`);
</script>
<template>
<a-typography-title> Browsing {{ band?.name }} fiction </a-typography-title>
<story-list :prefix="pref" />
<story-list :prefix="`/band/${route.params.id}/stories`" />
</template>

@ -1,8 +1,16 @@
import { messages } from "~/lib/server/constants";
import { Band } from "~/models/band";
export default eventHandler(async (ev) => {
const id = parseInt(getRouterParam(ev, "id") as string);
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,
25,
); /* */
return {
...band.toObject(),
stories: stories /* .slice(skipAmt, skipAmt + 20 + 1) */,
total: stories.length,
...stories,
};
});