Good day !
Introduction
Coming home from the Devoxx conference in Paris, the main technology that I wanted to try out and explore was serverless.
Just to clarify what serverless is in a few words :
Serverless computing is a method of providing backend services on an as-used basis. Servers are still used, but a company that gets backend services from a serverless vendor is charged based on usage, not a fixed amount of bandwidth or number of servers. (Source : cloudflare)
I've been playing around with NestJS (a NodeJS framework) for some time now and wanted to try building a server using AWS lambda functions using NestJS for the backend of an application.
To speed up the process and have a nice base to kickstart my projects, I've built a simple repository (usable as a template on Github). It contains the barebone structure of a NestJS project and the necessary configuration to deploy it to AWS.
Project
What to expect
This project contains a simple "Hello world!" endpoint, a handler that will be used as our serverless function and a basic serverless.yml file.
Getting Started
Prerequisites
You will need an AWS account, and the usual NodeJS development tools (Node, NPM).
Install the Serverless CLI using npm install -g serverless
and run the aws configure
command to setup your CLI.
Installation
git clone https://github.com/alexbdet/https://github.com/alexbdet/serverless-nestjs-blankapp.git
cd sls-nest-blankapp
npm install
npm run build
sls offline
Hit localhost:3000/dev in your browser and if everything is setup correctly, you should see our lovely "Hello world!". You're all set !
sls offline
allows you to run the project locally, if you'd like to deploy the server use :
npm run build
sls deploy
This command builds the necessary services to run your server on AWS (API gateway to reach the function, and the lambda function itself). You can use the AWS console to see the details of the built services.
If you'd like to uninstall your server from AWS and remove the services, use :
sls remove
What's next ?
Check out the NestJS documentation to get started with this framework, and the Serverless website to learn more about the serverless.yml file.
Thanks !
Thank you for reading, I'd be happy to help out with any questions or fix any problem with the repo should the need arise.
Have a great day !
Top comments (0)