From the course: Mastering Nest.js: Build Scalable Applications with Mastery in Nest.js Framework

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Rendering template on server

Rendering template on server

Alright, to begin with, we are going to focus on rendering templates on the server and then we will gradually attach MySQL to them. So let's see how to render a template. We will need to install two important packages. I'll give the command npm install at nestjs slash platform hyphen express and the templating engine ejs. Now after installing these packages, I'll create a views folder inside the root directory and define a file named home.ejs. I'll give the steady HTML boilerplate, I'll change the title to my store, and we'll give an h1 and the scriptlet with a message variable. Now in the app controller, I'll give the get route handler with a route path set to my store, and a method render page. Defining this inside the app controller because the app controller is going to get bootstrapped first when the application is rendered. So we will keep the homepage inside the app controller. Inside this method, I will return an object with the message property, welcome to homepage. So we are…

Contents