Jaanus
Jaanus

Reputation: 16551

NodeJS folder structucture, view files placing, routing SPA

I have been learning for NodeJS for few days now, and there are tons of example projects, but what I am interested is Express + Angular + MongoDB + Single page application.

So best one out there is ofcourse the mean.IO.

I have been disassembling this project, and I want to use the best practice, but I have hard time understanding this.

The project uses Jade view, whose files are at /app/views. On the other hand, half of the are view files under /public/view. There is index.jade and index.html. Whaat?

Why aren't they in the same location, and where should I store them actually then?

Furthermore half of the page(articles part after logging in) seems to handled with angular routing, so it looks like SPA, which is nice, but logging in, creating account do not follow this architecture and keep reloading the whole the page on new link browse.

When doing SPA, how should I handle the routing between Node and Angular, who is responsible for it?

Upvotes: 0

Views: 156

Answers (1)

kkemple
kkemple

Reputation: 992

First question: the index.html file is used for client side views, the index jade file actually just returns a page with an ng-view tag, then angular loads the default view.

Second question: the reason login and register hit the server is because a session still needs to be set for the user once they log in or register, plus there needs to be server side actions that happen like validation and what not. You could move this to ajax but a request needs to hit the server. They left it lean so you could make that decision for yourself.

I hope this helps.

Upvotes: 1

Related Questions