

Let’s start by adding Tailwind CSS and PostCSS to our project: npm install tailwindcss postcss autoprefixer postcss-cli

This step of the tutorial is adding Tailwind to our project and configure it. The last line, app.use(express.static(path.join(_dirname, 'public'))), tells Node that we store the static assets in a directory named public. The last step is to specify the directory from where to serve static assets such as JavaScript, CSS, images, and so on. Going further, the second line ( app.set('view engine', 'pug') ) tells Node what engine to use. Now, Node knows where to look for our Pug templates. With the first line, app.set('views', path.join(_dirname, 'views')), we tell Node what the source of our templates is. Now, let’s see what the code below does: app.set('views', path.join(_dirname, 'views')) app.set('view engine', 'pug') app.use(express.static(path.join(_dirname, 'public'))) Thus, import the path module as in the line above. The path module allows us to work with directories and file paths, which we need when we serve static assets such as images, for instance. The first step is to import the path module, which comes with Node by default. Before we can start coding, we have to set up views and static files. Project structure or project tree is as follows And most of this setup came from serverless template. Again, I am not showing an entire file, just some important parts. I followed instructions I found on Google and it is pretty straightforward.Īfter I got everything set up and ready, it was time to set configuration in serverless file. I am using serverless framework, but I will not write about setting up that framework.

Set up computer and environment and project structureįirst step was to set up my computer to deploy code to AWS, since this was the very first project I did that included Lambdas. 124,8 MB (JS project) for the same code.ġ. And it was a good decision because difference in code size was 984,9 kB (TS project) vs. My first idea was to write this in plain JavaScript (and I’ve also done that), but since serverless framework had a TypeScript template, I decided to go with it. Since I couldn't find a solution for combo I needed, I decided to write an article about it.

AWS Lambda seemed to be a perfect fit for this. On the other hand, we needed something that we can reuse or extend for other purposes. The fastest and the easiest way was to gather all necessary data directly from frontend and generate PDF from it. The issue we had with resolving this task was that the data we needed resides on a third-party backend and it was impossible to get any update regarding this in short time. Last week team I am working in got a task to create possibility for users to get data extracted to PDF file on click on a button.
