6

I'm currently developing a community (like a lightweight "social network") for a limited (local) target. This is the first project where SEO doesn't matter and where I can happily exclude no-js users. That's why I'm thinking to start the project over and write my first site that is completely build with Javascript and my first Node application for educational reasons.

Details so far:

Browser: jQuery, maybe JavaScriptMVC (there are some things I don't like about JavaScriptMVC (like the routes), maybe I write my own little MVC or do you know a better suited framework?)

Server: Node.JS, Express framework, (maybe socket.io or nowjs for further features)

I got a few questions so far. I know it's better to ask a single question but there are more or less connected:

  • Express looks really nice but I'm missing MVC. I couldn't find any project that implements mvc and is build on Express. Is there a reason for that? Routing is nice in Express but I need a way to spread code across multiple files (controllers would be the best way I guess, the application won't be small and I need it maintainable)

  • The application will be more or less completely based on AJAX (json) requests. Is Express the right framework for such applications, anyway? I think the best way to write this project is to expose a json REST api which can then be queried by the web application over AJAX and by a mobile device app (which I'm also going to write). In my opinion Express' route system is quite suited for REST. But feel free to recommend other frameworks.

Travis Webb
  • 14,688
  • 7
  • 55
  • 109
Eliasdx
  • 2,190
  • 2
  • 23
  • 33
  • For RESTful apps with express, I just started to play with https://github.com/visionmedia/express-resource . Looks promising. – GrGr Oct 17 '11 at 14:48

3 Answers3

5

Have you seen Swagger? An API server available in Node.js with an automated UI Generator.

Swagger
(source: wordnik.com)

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
sbstjn
  • 2,184
  • 1
  • 15
  • 13
4

To answer your primary question, yes there are controllers in Express. They are more akin to Sinatra (express is modeled after Sinatra rather than Rails). By that I mean they are light-weight method mappings to routes you define.

Browser: jQuery, maybe JavaScriptMVC (there are some things I don't like about JavaScriptMVC (like the routes), maybe I write my own little MVC or do you know a better suited framework?

I'd go with spine.js or backbone.js personally.

Express looks really nice but I'm missing MVC. I couldn't find any project that implements mvc and is build on Express. Is there a reason for that? Routing is nice in Express but I need a way to spread code across multiple files (controllers would be the best way I guess, the application won't be small and I need it maintainable)

You can spread files out all you want. I answered this here.

The application will be more or less completely based on AJAX (json) requests. Is Express the right framework for such applications, anyway? I think the best way to write this project is to expose a json REST api which can then be queried by the web application over AJAX and by a mobile device app (which I'm also going to write). In my opinion Express' route system is quite suited for REST. But feel free to recommend other frameworks.

I haven't built a 1 page app yet in node but from what I can tell, almost everyone seems to be using socket.io with backbone. That's not to say you can't, just that you'll find more examples that way.

Community
  • 1
  • 1
Chance
  • 11,043
  • 8
  • 61
  • 84
  • I don't know if socket.io is too heavy for just showing sites. However it'd be nice to broadcast status messages in realtime and I think I'm going to implement a chat later, so I'd need it anyway. But then I still need REST or similar for the mobile application. Hmm, so many ways :D. – Eliasdx Oct 16 '11 at 16:44
0

You could check out Sails. Its structure is based on Rails.

mikermcneil
  • 11,141
  • 5
  • 43
  • 70