Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add controllers plugin #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

turtleDev
Copy link
Contributor

@turtleDev turtleDev commented Sep 17, 2016

Why?

So far, we've been creating a local controller object manually for each individual route plugin. It is a process that has to be repeated for every new route plugin that is added to the app.

This patch proposes the addition of a controllers plugin that decorates the server object with a .controllers() method. The method generates an object representation of the app/controllers folder, which simplifies the process of writing route plugins.

I believe that this approach is superior to the current one in two regards:

  • It makes the code more DRY
  • It eliminates the need for a cousin import. (where controllers were require()'d by going up a directory and then into another sub directory)

cousin imports are a code smell, since ideally all imports should be from siblings and decendents, not from cousin or parents.

Considerations

some area's of concern:

  • In the current system, only controller's that were specifically require()'d were available. However in the new system, all controllers will be available. This goes against the principle of least privilege. Although that won't be the end of the world
  • This will only add more to the complexity. Since jolly doesn't have an express philosophy, while this might not be breaking any conventions, it does add to the pile.

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

Successfully merging this pull request may close these issues.

1 participant