I have the following things I want to accomplish. In the end I feel it is just a simple thing but I can't get my mind wrapped around it architecture-wise.
I have a simple NodeJS Express server that serves an AngularJS frontend via
this.app.use(
express.static(__dirname + '/' + settings.env)
);
Now I have some API Endpoints that are supposed to be at least of RESTful path-naming. I have AJAX Calls to them on some button clicks on the Front-End.
Let's say one Button is to load and view a list of "Loans"(Whatever this might be): GET /loans
.
The Angular frontend reacts on and writes links like this: /#/loans
That was Question Part 1: Why is this? And more importantly: Is it common practice to keep it like that?
Now I am also sending out e-mails that have Buttons in them that the receiver can click. Right now I cannot remind anymore why I wanted this, but it made sense when I decided to.
I want to be able to request GET /loans
as path on that button click in the e-mail and have the Express routing decide whether to run logic and return a json or to "reroute" to angular to render the page.
That was Question Part 2: Is this something I should or should not want to accomplish? And if I still want to accomplish it what would be the best way?
I'll have another shot on the 2nd Part in Short:
I want to decide depending on the Accept
-Header whether to return a json or to "reroute" to static files.