2

I'm trying to get some pointers on what the best methodology to follow for a web application would be.

First, some background: I've built two different APIs using Node.js where Node serves the data to clients using a JSON interface. The clients have both been iOS applications, making heavy use of Socket.io and Express.

Now, I'm trying to get into the world of website development- I'd like to be able to create a single-page application that is run in the browser, again using Socket.io and Express. However, I'm hung up a bit on what exactly I should do.

  • Should I host my site out of Nginx/Apache and use Node as simply a "data" server, funneling data through JavaScript on the client to update the site HTML?
  • Should I host it all through Node, adding routes for files as I go?
  • Should I attempt to create some form of "send a command via Socket.io to the client JS to build the page dynamically" type of framework?
  • Should I do something else entirely? Basically, I'm an iOS and API developer unused to web technologies overall, trying to figure out how best to use what I know about Node's data serving methodology and apply it to a client side web app.

I've been reading tons of information online and, while helpful, it seems that everything seems to assume that I know a lot about web development already and am just trying to adapt it to Node, whereas instead the opposite is true: I know about Node but not about web development. I've looked into the MEAN stack, for example, and while I love the concept it doesn't appear (at first blush) that Angular is any more suited to Node than, say, jQuery (I'm sure I'm wrong here- there must be some reason 'MEAN' is a thing).

Any input is greatly appreciated!

5
  • 1
    This is a very well worded question, but it is just on the edge of recommending education and/or tools. I am not certain that this question is on topic for Programmers.SE Apr 5, 2014 at 1:24
  • cross-posted and closed at SO: stackoverflow.com/questions/22875032/…
    – gnat
    Apr 5, 2014 at 13:17
  • I was told on SO that the question should go here. Apologies. Also, in regards to the hold, I can see how this question would seem to elicit opinion based responses. What I was actually trying to learn is, "what is the 'official best practice' manner in which to do this" rather than opinion based.
    – jssblck
    Apr 5, 2014 at 17:34
  • 1
    @gearheadalex unfortunately many people on Stack Overflow suggest reposting for any question that doesn't fit on SO to P.SE. All stack exchanges have the reasons of 'too broad' and 'primarily opinion based'. If something is closed as such on one SE, it would likely be closed as such on a tangental stack exchange site too. You need to look at what is necessary to address those issues before reposting it. Ideally, one would flag it for migration instead of reposting it so that a moderator can look at it and say 'nope, this would be closed there too'.
    – user40980
    Apr 5, 2014 at 18:06
  • I would suggest looking at Why was my question closed or down voted? on our meta site and look to identify what parts of this question can be made into a better question that is more focused on a problem that can be solved.
    – user40980
    Apr 5, 2014 at 18:08

2 Answers 2

2

Should I host my site out of Nginx/Apache and use Node as simply a "data" server, funneling data through JavaScript on the client to update the site HTML?

Many people recommend this exactly. This article is about yesod, but I think it applies:

  • As fast as Warp is, it is still optimized as an application server, not a static file server.
  • Using Nginx, you can set up virtual hosting to serve your static contents from a separate domain. (It’s possible to do this with Warp, but a bit more involved).
  • You can use Nginx as either a load balancer or a SSL proxy. (Though with warp-tls it’s entirely possible to run an https site on Warp alone.)

Then

Should I attempt to create some form of "send a command via Socket.io to the client JS to build the page dynamically" type of framework?

That is what many people do, using frameworks like angular/ember/knockout/... It is a natural way of developping a single page webapp.

The main drawback is managing js-less browsers, used by blind people & search engine bots. A native app would not be of any help here, so you have to decide if those use case are important, knowing that some solutions may exist (such as crawling your own webapp with a headless browser to build a static limited version served to js-lss browsers).

Should I do something else entirely? Basically, I'm an iOS and API developer unused to web technologies overall, trying to figure out how best to use what I know about Node's data serving methodology and apply it to a client side web app.

No one can answer this one. It depends if you want to learn something new vs deliver something fast. And also your target audience. Discovering any new technology is scary at first. The fact that a web-app backend can be anything you want means there are constantly new backend tech appearing all the time. You have chosen node.js; I would focus on this first, maybe ignoring nginx for the moment.

The knowledge about web client development is hard to acquire, but is very reusable. And once you know node.js, you can read more easily about other backend techs.

1

Should I host my site out of Nginx/Apache and use Node as simply a "data" server, funneling data through JavaScript on the client to update the site HTML?

Something should be responsible for the port 80. It should be either Nginx/Apache or Node. If you're going to use Node you can use it as your webserver.

Should I host it all through Node, adding routes for files as I go?

I can't totally get this one. You can implement your dynamic routes using Express for example and it's very simple. Also you should generally consider requests as URI not Files.

Should I attempt to create some form of "send a command via Socket.io to the client JS to build the page dynamically" type of framework?

You can go for Socket.io if you wish, however you're not limited to. AJAX is the other option, however you won't need it if you have already Socket.io in place.

Should I do something else entirely? Basically, I'm an iOS and API developer unused to web technologies overall, trying to figure out how best to use what I know about Node's data serving methodology and apply it to a client side web app.

If you really need to have a single-page/real-time application, then Node is a good choice. If you need just a simple website an scripting language like Python or PHP could be a better choice.

Regarding Angular and jQuery, the first one is more of your luxury house in Beverly Hills but the second one is kinda piece of land -- well, anywhere on earth!, that you can build anything on that: A luxury house, a farm or a factory. If you read about them separately you will simply understand that Angular is more willing do to things for your -- in it's own way, in contrast with jQuery that is more willing to help you out doing things on your own and in your own way. Both of them have their own use cases, so don't simply dismiss any of them, they're totally different animals.

Not the answer you're looking for? Browse other questions tagged or ask your own question.