Book Image

Beginning Server-Side Application Development with Angular

By : Bram Borggreve
Book Image

Beginning Server-Side Application Development with Angular

By: Bram Borggreve

Overview of this book

Equip yourself with the skills required to create modern, progressive web applications that load quickly and efficiently. This fast-paced guide to server-side Angular leads you through an example application that uses Angular Universal to render application pages on the server, rather than the client. You'll learn how to serve your users views that load instantly, while reaping all the SEO benefits of improved page indexing. With differences of just 200 milliseconds in performance having a measurable impact on your users, it's more important than ever to get server-side right.
Table of Contents (10 chapters)

Implementing a Web Server


Now that both our applications can be built, we can move on to creating a simple server to host our applications.

In order to do this, we will create a simple Node.js server based on Express.js.

We will define our server in a TypeScript file called server.ts and run this file using the ts-node binary that we will install.

Note

The current implementation of Angular Universal depends on Node.js as it is implemented in JavaScript.

It is possible to run Angular Universal apps using other servers, such as ASP.NET, although under the hood the ASP.NET server will invoke a Node.js process to handle the Angular Universal part.

An example repository of how to run Angular Universal can be found here: https://github.com/MarkPieszak/aspnetcore-angular2-universal.

Installing Server Dependencies

We will install the ts-node binary that we will use to execute our server file. Additionally, we will install the rendering engine that will be used by Express.js to load our Angular Universal...