Skip to content
This repository has been archived by the owner on Jan 25, 2020. It is now read-only.

fix directory.js to use the correct mountpath #32

Closed
wants to merge 1 commit into from
Closed

fix directory.js to use the correct mountpath #32

wants to merge 1 commit into from

Conversation

felipeleusin
Copy link

When using directory option, all the routes were being mounted on with their base route being relative to their physical path. I just removed this to use the router directly.

I can try including some tests for it. I just really haven't gotten around the way the tests are written in this project.

@timmywil
Copy link

This is a blocker.

@jasisk
Copy link
Member

jasisk commented Apr 29, 2014

Hey guys. Thanks for bringing this to our attention. The lead maintainer is currently serving jury duty but we're looking into this now.

@jasisk
Copy link
Member

jasisk commented Apr 29, 2014

With enrouten 1.0.0, we've changed how the directory option works. Mounting based on folder structure is now by design. That said, you can still accomplish something similar to the older style (load everything without any submounting) by switching to the index option.

Here's an example. Granted, you don't get the automatic traversal or module checking but traversal is extremely straight forward and the module checking is a defensive measure that isn't necessary when the automatic requiring magic is gone.

@felipeleusin
Copy link
Author

Got it. I think I missed this when I read the documentation. I guess I'll update my directory structure to account for this and see how it goes.

@jasisk
Copy link
Member

jasisk commented Apr 29, 2014

No problem. For our purposes, we found this new loading structure to work well (our paths generally mirrored out directory structure anyway) but let us know if you have any trouble with it.

@jasisk jasisk closed this Apr 29, 2014
@timmywil
Copy link

I think I prefer the other way so I don't have a bunch of index.js files.

@felipeleusin
Copy link
Author

I've just updated an app to this new conventions, felt good and I liked the result. Had to change the way I initialized my tests but the end result is neat.
My only beef it's that I had to concentrate routes that depended on a param in the index.js file and it ended bloated.

For instance, I had /controllers/venues and inside it I had the index.js and the map.js. The map.js route was /venues/:venue_id/map now I'm forced to put this in the index.js. Before I could keep almost one file per route design that I liked. Sure there are ways to fix this but I would lose some of the "magic" from enrouten that I liked from the start.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants