final-hill / cathedral

Requirements Engineering
GNU Affero General Public License v3.0
0 stars 0 forks source link

Move solution slug checking logic to middleware #163

Closed mlhaufe closed 6 days ago

mlhaufe commented 1 week ago

Currently, nearly every page has the following pattern:

import SolutionRepository from '~/modules/solution/data/SolutionRepository';
import SolutionInteractor from '~/modules/solution/application/SolutionInteractor';

const router = useRouter(),
    route = useRoute(),
    slug = route.params.solutionSlug as string,
    solutionInteractor = new SolutionInteractor(new SolutionRepository()),
    solution = (await solutionInteractor.getAll({ slug }))[0];

if (!solution)
    router.push({ name: 'Solutions' })

Move this logic to middleware:

https://nuxt.com/docs/guide/directory-structure/middleware

mlhaufe commented 6 days ago

Still not working.