I started to migrate my pet project from pure VueJS to Nuxt, because of the tone of its useful features. My frontend part has a number of pages that are only accessible for admin users, but it becomes very tedious to write the same validate methods for them.
Things start to be better when I write admin validation in the middleware component and moved all admin pages in the one subdirectory. But in that case, you also need to manually write this middleware in all admin pages, which leads to bugs, when you just forget to do so.
So is it possible to somehow add middleware for all admin pages at once?
I see only one solution for it: write a module that before creating Vue instance, looking for its path in the project, and injecting middleware if the path starts with @/pages/admin. But I'm not proficient in Nuxt nor Vue, so I can't understand how to do it properly.
I believe that it is quite common problem for big websites and don't understand why I can't find any solution to this.
So how to add the same validation for pages laying in the one subdirectory?