veliovgroup / flow-router

🚦 Carefully extended flow-router for Meteor
https://packosphere.com/ostrio/flow-router-extra
BSD 3-Clause "New" or "Revised" License
202 stars 29 forks source link

Separate router files #80

Closed jasongrishkoff closed 2 years ago

jasongrishkoff commented 4 years ago

Hi there, I've got one big router.js file that has a whole bunch of routes inside it. For example:

FlowRouter.route('/', {
    name: 'home',
    async action(params, queryParams) {
        const { default: Layout } = await import('/imports/client/layout')
        const {
            default: Home,
        } = await import('/imports/client/home')
        mount(Layout, {
            content: <Home tab='home' page={Number(queryParams.page)} />
        })
    }
})

I've got 100+ such routes in this file -- many of which are only relevant for certain users (such as an admin).

Is there a way to dynamically import that route, but ONLY if the user is an admin? It's easy enough to dynamically import a file containing all the admin routes, but unless I provide the route as part of the main package bundle, the admin page I'm trying to visit will result in a 404.

Appreciate any guidance!

J

dr-dimitru commented 4 years ago

Hello @jasongrishkoff ,

Sorry for the late reply, missed this one. As of right now there's no way to dynamically create new routes during runtime.

I guess we should consider it as a feature for next major release.

dr-dimitru commented 2 years ago

@jasongrishkoff this won't fix at the moment (I'm planing to rewrite this package from ground zero for the past three years, unless this happens, there's no way to implement dynamic routes within the current codebase), duplicates #76