0

I'm currently working on a web application based on the popular MEAN stack (MongoDB, Express, AngularJS and Node.js). As I am still struggling with some aspects of node.js, I would like to ask for your advice and opinion on a major architecure decision of mine.

As I found Jade rather ugly (notation-wise) and did not want the server to render webpages (for cpu power saving reasons), I chose to always send back prepared html files/templates.

Example:

app.get('/', function(req, res) {
  res.sendfile("public/index.html");
});

On the client side, I then initiate further Angular-JSON based communication to realize REST webservices to instantly get and fill in the needed data. Any reasonable arguments against this approach or maybe good points why I should be using a render engine on the server side?

Besides, does anyone know a good online tutorial for a multipage web application featuring user registration/validation, authentication process, rest webservices and so on? Something newbies can take a look at to get a feeling of how to structure a medium to large sized node.js application well? I've been googling for days now but feel that all tutorials I found were always missing essential ingredients or were rather "elementary".

Thanks in advance. Igor

Igor P.
  • 1,407
  • 2
  • 20
  • 34

1 Answers1

0

I started with Node.js like 2 month ago and now I am starting a project following this same approach.

In the same way, I am not using a "render engine", mainly because I am planning to use my client code (angular) to create a hybrid application using cordova (phoneGap).

I learned a lot from the tutorials of Node.js in Pluralshigh:

Finally, regarding security, "Passport" is a great library to implement authentication.

btw: I am using Token-Based Authentication.

And the answer to "how integrate Passport with tokens", I found it here:

passport-local with node-jwt-simple

Community
  • 1
  • 1
ZeroCR
  • 316
  • 4
  • 6
  • Hi, thanks for that. Good to know, that my approach is not totally wrong or violating essential rules. Still, other opinions and experiences would be great. – Igor P. Aug 26 '14 at 21:28