jansmolders86 / mediacenterjs

A HTML/CSS/Javascript (NodeJS) based Media center
http://mediacenterjs.com
1.29k stars 245 forks source link

ported movies app to express app #59

Closed th3l0g4n closed 10 years ago

th3l0g4n commented 10 years ago

As proposed in Issue #57 i ported the movie app for demonstration. Actually anything relating to the app could be placed into the app folder itself. There needed to be made slight changes to the routing, but everything should work as before.

PS: Im quite new to github workflows, so im sorry if this wasnt the right way to 'present' the changes.

jansmolders86 commented 10 years ago

Hej Th3I0g4n,

Thanks for taking the time to submit this pull request. This is exactly the way changes should be presented so don't worry. I've taken a look at your setup and I understand now what you mean with the express setup.

Currently, MediacenterJS is based on the MVC configuration Express provides. An example of this setup can be found here: https://github.com/visionmedia/express/tree/master/examples/mvc

The main reason I chose this way of doing this is that it provides the developer a solid base to start with. Routing is not really a concern for a basic app and can be easily extended using a JSON.

Would you disagree?

Thanks again! Jan

th3l0g4n commented 10 years ago

My assumption was, that by providing the possibility of mounting apps directly, the creator has some more 'freedom' in designing it. I can imaging that there will be some more complex plugins where dealing with a fixed routing structure can be rather complicated. Also by using the eventsystem you can give the opportunity to hook into processes taking place in the coreapp which it might emit (e.g. 'plugin added', 'client connected') or giving access to the underlying websocket.

I know that by going this plain way i suggested, maybe some 'quality-checks' cannot be performed to assure that the plugin will work at all. Maybe its something in between?

jansmolders86 commented 10 years ago

Yup I think you are right. Currently if a developer is building an app that uses more complex routing structures he needs to add a route.js in the root of his app. In this file, he can declare his routes in a JSON format like so:

  {
     "complex": [{
         "method": "get",
         "path": "/NAME/this/is/a/complex/route/:additional?options*"
     }]
 }

when using this technique combined with

   exports.complex= function(req, res, next){ 

This is basically the same as when you would write:

 app.get("/NAME/this/is/a/complex/route/:additional?options*", function(req, res, next) { 

I know this is an additional step a developer has to take, but I think this will eventually give the platform the best of both worlds. I gives the developer freedom to write the code he wants, but also assures coding standards and quality control like you said.

I would love to hear your thoughts on this solution.

Thanks!

th3l0g4n commented 10 years ago

Ok, i think i just fully understood your routing-strategy - my fault :/ If i'm right, the part of adding event listeners to the apps, could be achieved by adding more reserved keywords which could serve special purposes (like...well, event listening).

Dont mind closing the request if you want. If i can help you lifting MCJS into beta status some other way, i would be glad to help.

jansmolders86 commented 10 years ago

Yup, you are totally right. I hope this strategy makes sense. I think time will tell if people will adopt this system or we will have to make the move to your initial idea in the future. Whatever the case i'm very gratefull you took the time to help out. Feel free to contribute, post ideas or bugtest as much as you like. The help is really appreciated. Thanks again!