UNPKG

baked-recipe-admin

Version:

Baked is an opinionated framework for .NET in backend and Nuxt in frontend. This is a recipe package that brings together all the components one needs for an Admin UI.

28 lines (23 loc) 505 B
import { createError, useNuxtApp } from "#app"; export default function() { const { $pages } = useNuxtApp(); async function fetch(name, { throwNotFound } = { throwNotFound: true } ) { if(!$pages[name]) { if(throwNotFound) { throw createError({ statusCode: 404, statusMessage: `'${name}' Page Not Found`, fatal: true }); } else { return null; } } return await $pages[name](); } return { fetch }; }