Do we need Node.js and Express.js while working with Angular2? - node.js

I built a sample web application using the following -
Angular 2
TypeScript
ASP.Net WebAPI 2
Mongo DB
Karma/Jasmine
Node.js (only as a server, just to the extent as specified in Angular2 Quick Start)
Considering the above tech stack do we have any need of using Node.js or Express.js for building a production web application? Is any of the above tech is replaceable with Node/Express, for better performance/memory utilization/code maintainability/faster development?

You'll need Node.js for development time tooling - for instance, TypeScript compiler and running Karma/Jasmine tests.
Regarding Express.js - you can do without it. An Angular 2 application does not rely on a back end framework. It could be served as static assets from a web server. Pick any back end framework that suits your needs.

Related

How and where to add unleash-client for asp.net and node.js angular typescript application

I am trying to add https://github.com/Unleash/unleash-client-node to node js angular project. I am not a developer but just want integrate feature toggle in one of my projects. The application tech stack contains asp.net core, nodejs, angular and type script. What is the exact location(file) to configure the unleash-client so that I can see the application in the server. I have tried many ways and terribly failed due to my naive coding skills. Can some on give some more details on the integration.

Best way to implement Angular Universal

I suffer a lot in the past with angular apps and social media, so I'm glad to see that Angular Universal is being developed.
Currently I have some apps that are Angular4 as front end, and Java with Spring as backend. As far as I know there are some ways to implement Angular Universal here but they seem pretty complex (at least is what I read). So I want to know if that is in that way or not...
But anyway, my main question here, is because I saw that in order to implement Angular Universal we should have (ideally) to make the backend with nodejs, how to structure these two technologies, I mean... Should I have Angular app as a frontend app and Nodejs app as a totally different backend app (just like Java) where both are connected with web services? Or should I served Angular4 SPA direcly from Nodejs views?
And where should I place Angular Universal here?
Now that Angular CLI v1.6 is out, there's native support for building Angular Universal into your projects easily using Node.js! Essentially, you would ng build --prod to create a dist/ folder, and then create a simple node back-end and connect to your dist/ folder containing your front-end code. This article gives a great step-by-step guide: Angular server-side rendering in Node with Express Universal Engine.
When you use Angular Universal, it is going to be a single process (Operating system process) that hosts and serves your Angular pages.
In production you may have multiple such processes behind a load-balancer.
Your back-end APIs (if developed in Javascript) may be hosted in the same Node server or in separate server.
The Angular Universal setup steps are detailed here in the official documentation.
However, I had a few wasted hours to find out the following point
Webpack 3 is not compatible with ts-loader versions higher than 3.5.0. At the time of developing this, the latest version of Angular CLI is 1.7.2 which uses Webpack 3.*. Hence, while setting up Angular Universal, install ts-config#3.5.0
Finally, here I have a seed project for Angular Universal. It uses Vagrant to locally setup the development environment. Also, by tweaking an environment variable in your local host machine, you can run it in a production mode in a Docker container. The steps to run it are detailed in the readme file.
If you refer to my Dockerfile in the above Github link, its entrypoint reads:
ENTRYPOINT ["pm2-runtime","start","/home/aus/dist/server.js"]
So, you see, it's just a singe command, and your app is up and running at port 4000. Of course you can use other command line parameters to provide memory limit, port and so on.

Integrate Node.js with Angular 2 application

I am creating an angular 2 project which will use Node.Js as backEnd and Node.Js will make calls to 3rd party external APIS(Like Gandi) which accept calls only from Python, PHP or Node.Js.
I have chosen Node.Js.
I have called few APIs from Angular 2 services using HTTP protocol. Now I do not know where to write this Node.Js code and how to Integrate this Node.Js code with Angular 2 services.
I think, Just a sample application or sample architecture which is a combination of Node.Js and Angular 2 will help a lot.
Do I need to create Restful services using Node.Js?
If Yes, Do I need to use Express.Js also for server purpose?
Note: I do not want a Mean Stack application(No Mongo DB)
Actually it's pretty straightforward.
What I'd do is to simply consider the Angular 2 app on the frontend and the Node.Js API on the backend as independent projects. It's very likely that they will run on different providers (eg. Firebase for Angular 2 app and Heroku for the Node.js server) so it makes sense to handle them as 2 different projects with it's unique dependencies.
I have recently done a similar project, using Angular 2 + webpack as frontend and Django on the backend: https://github.com/damnko/angular2-django-movies
Hope this makes sense, otherwise please let me know
i think this repo will serve your purpose.
https://github.com/singh15/feed-server
which is using twitter api to get data and send that data to any front-end.

Do I need Node.js or Express to deploy my Angular 2 app?

I am working on a food purchase web app. The app has already been launched on mobile (Android). Now we want to build a web version.
The backend of this app was built using Node, Angular and Firebase.
I would like to know if I can only use Angular 2 (without Node.js) for the web application. What the web app will basically do is to:
User authentication
Consume Backend API
Checkout, after purchase
My major concern is, do I need Node.js for anything? Or is Angular 2 just enough for my frontend development and deployment?
Angular is your front end.
Nodejs is your backend.
Firebase is a cloud backend that I assume you're handling your user Authentication in....it's easier than DIY if you aren't backend savvy.
Depending on what Node is doing, then you might be able to remove node and rely entirely on Firebase(big maybe...).....I suggest not touching anything becuase you clearly aren't a backend engineer. Node is probably hosting your app's API and/or connecting to your database.
Yes, you can switch to a different backend from node like PHP or .Net and it will work with Angular2. You will need some sort of backend(Angular2 is 100% front End).

node.js server for ionic application

I am developing a mobile application using ionic framework. I want to use node.js for developing the server to make REST api calls.
Where should the node.js code be included in the project?
How to deploy such an app as apk? and how to test it?
Ionic is based on cordova and it is used to create mobile applications in javascript.
Node.js is based on V8 and it is used to create backend (server) applications in javascript.
Node.js code cannot run on mobiles.
So you have two seperate projects.One is the frontend ionic mobile app. And the second is the backend nodejs app.
To make a connection between the two, as ionic uses angularjs take a look at angular's http service. After that you can organize your code in services. For example:
http_calls_service.js or api_service.js
As for the testing there are several frameworks to work with. Take a look at this.

Resources