Comments (9)
I was in for that idea initially. So just to be clear, nothing stops you from putting routes inside the module, but if you consider that your module might be redistributed between different apps than you will most likely look look to define routes in application wide config file.
from mantra-sample-blog-app.
Can i load my routes as part of an
app.loadModule(someModule);
from mantra-sample-blog-app.
Here is what my client/main.js file looks like
import {initContext} from '/imports/configs/context';
import routes from '/imports/configs/routes.jsx';
import {createApp} from '/imports/libs/mantra';
import coreModule from '/imports/modules/core';
import commentsModule from '/imports/modules/comments';
import _homeModule from '/imports/modules/_home';
import _homeRoutes from '/imports/modules/_home/configs/routes.jsx';
import _usersModule from '/imports/modules/_users';
import _usersRoutes from '/imports/modules/_users/configs/routes.jsx';
import _colorsModule from '/imports/modules/_colors';
import _colorsRoutes from '/imports/modules/_colors/configs/routes.jsx';
const context = initContext();
const app = createApp(context);
app.loadModule(coreModule);
app.loadModule(commentsModule);
app.loadModule(_homeModule);
app.loadModule(_usersModule);
app.loadModule(_colorsModule);
app.loadRoutes(routes);
app.loadRoutes(_homeRoutes);
app.loadRoutes(_usersRoutes);
app.loadRoutes(_colorsRoutes);
from mantra-sample-blog-app.
Ok.. thanks !
from mantra-sample-blog-app.
I like to place routes into a common place rather loading them from modules. I'm not disagreeing with it.
Then it's easy to visualize the whole app at a single place and modules does all the UI/action stuff.
Can I get some counter arguments and you reason on putting routes next to the modules?
from mantra-sample-blog-app.
My thinking is around the CMS side of things. if i can add a module that represents "Events" and it will come with the backend routes to create / manage / update / delete an Event item.
I'm playing with this concept of a modular CMS build-pack. Where a module can represent:
- widgets that can be used to craft the UI experience
- admin side features (including specific module admin routes)
a common place for routes then works for the main app.
I think for this to work.. the 'admin' routes would need to load up in the Module main.js file. And come loaded with the app.loadModule() call.
thoughts?
from mantra-sample-blog-app.
I don't mean to bring this back to life if it was finished, but personally I think separating the routes by their modules makes the most sense and means the modules are easier to maintain. From a CMS perspective, or any project in my mind, each module should be self contained. A "Users" module for example: EVERYTHING related to the users is put inside it, including the routes used for accessing them.
In the current setup you could have the users module, make a change, and need to go to the "Core" to update the routes associated to your change, but if you are using that same module in multiple projects then you have to do it for each individual project. This means that I have 3 apps all using the "Users" module I created, I have to open all 3, modify the core of all 3, before I can run my E2E and other tests, finally leading to push the update to staging/production. By putting the routes inside the module it cuts out the copy & pasting someone needs to do to use the module in different projects. It also makes it fully self contained, meaning you don't need to go outside of the module to update any aspect of it, meaning it's easier to maintain and expand.
As a general design rule I seperate everything down to core modules. I did this previously with packages in Meteor, but with the ability to use imports in 1.3, I will likely move away from that. This limits the amount of time spent hunting for where the component is that is having an issue. "Oh? There's a problem on 'example.com/user/ID/edit' CLIENT 1? I'll get right on that!." If you have multiple modules handling routes that start with /user then in my mind you didn't design things out well. Seeing that URL I should be able to tell what module it's related to. In the same thought process if I don't know where things are I can easily figure out what module I need to look at, and from there use it's route list to find the problem component if it didn't become evident. This helps immensely in the maintenance of an app, as well as in on boarding new team members who need to pick up and add new features, or help support older ones.
That's my thoughts on this. I'd be interested in hearing more. personally it comes down to ease of maintenance, expansion, and logical design.
from mantra-sample-blog-app.
im using dedicated routes in each of my modules.. no problem now.
The routes are defined in my configs folder as normal..
then my index.js sets them up
import methodStubs from './configs/method_stubs';
import actions from './actions';
import routes from './configs/routes.jsx';
export default {
routes,
actions,
load(context) {
methodStubs(context);
}
};
from mantra-sample-blog-app.
I moved to the same concept @payner35, I just saw @arunoda request opinions and I'm an opinionated person at time on certain topics 😛
from mantra-sample-blog-app.
Related Issues (20)
- MUI leeds to Uncaught Invariant Violation
- storybook fails with unmodified repo, and with meteor 1.3.2.4 HOT 5
- jsdom error on npm test HOT 3
- FlowRouter SSR don't work properly HOT 1
- Git project description demo URL needs updating HOT 1
- Meteor.uuid is deprecated and untrusted on the client side HOT 5
- Failed to parse SourceMap: http://localhost:3000/packages/5b3...a10.map HOT 2
- Comments on naming variables
- Unable to resolve some modules: lib/collections HOT 3
- broken link at top of https://github.com/mantrajs/mantra-sample-blog-app HOT 1
- why not testing server code with wallaby?
- In container file,Where is the arguments of composer function comes from? HOT 4
- Why fetch in composer? HOT 6
- How to check authenticated routes? HOT 1
- no .meteor.com anymore HOT 1
- Cannot Deploy to Galaxy from Mac (Due to binary NPM modules in dev dependencies) HOT 6
- how to bind some arg to all actions ? HOT 1
- loading component HOT 2
- This fails on my system with storybook (app and tests its ok) HOT 1
- FindOne instead find in post.single publication HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mantra-sample-blog-app.