vicecarloans / AWS-NestJS

Speridian Demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sample NodeJS Backend deploying to EC2

An Example of API Server created by Nest framework.

Description

Backend will expose 2 endpoints /cats and /.

Endpoints Description

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
}

Deployment Steps

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

About

Speridian Demo


Languages

Language:TypeScript 100.0%