next/server/api/band/[id]/index.get.ts
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ ee7ea24e4e
refactor(*): rename route
change "bands" to "band"

BREAKING CHANGE: breaks anything that tries to access `/api/bands/*`
2023-12-06 22:22:48 -05:00

17 lines
361 B
TypeScript

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();
if (!band) {
throw createError({
statusCode: 404,
message: messages[404],
});
}
return band.toObject();
});