An Example of API Server created by Nest framework.
Backend will expose 2 endpoints /cats
and /
.
GET /: Returning server info
GET /cats: Returns a list of cats. Supported query params offset and limit for pagination
GET /cats/{id}: Returns cat by id
POST /cats: Create a cat in database. Followed by CatDTO
export class CatDTO {
kind: string; // British Shorthair
image: string; // Link to Image
fact: string; // Fun fact about the cat
}
The API backend exposes port 3000 so make sure EC2 security group is configured accordingly
Install Node on EC2 VM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
Activate Node Version Manager
. ~/.nvm/nvm.sh
Install Node to the environment
nvm install node
Verify if Node is installed
node -v
Install yarn
# Use this
npm install -g yarn
# Or
curl -o- -L https://yarnpkg.com/install.sh | bash
Install Git
# Perform a quick update on your instance:
$ sudo yum update -y
# Install git in your EC2 instance
sudo yum install git -y
Clone the repo
git clone https://github.com/vicecarloans/AWS-NestJS
After cloning the repo, go inside the folder and install dependencies
cd AWS-NestJS && yarn
Add Environment Variables
# Copy Environment Variables Manifest
cp .env.example .env
Update Environment Variables with correct info
vi .env
Build Application
yarn build
Run of Production Mode
yarn start:prod