Skip to content

RamaRaju-vj/webapp

 
 

Repository files navigation

Project Diagram

flow drawio

Initialize Node..

npm init

Installing pacakges, ORM & database driver

npm i mysql express  sequelize mysql2 dotenv    

npm install --save-dev jest supertest

Update Package.json

"scripts": {
    "test": "jest",
    "start": "node index.js"
  },
  "jest": {
    "testEnvironment": "node"
  },

Check Databases available & port connection

# Databases check (give mysql password)
mysql -h localhost -u root -p -e "SHOW DATABASES;"

# MySql Process check (give your system pasword)
sudo lsof -iTCP -sTCP:LISTEN -n -P | grep mysqld

API Enpoints testing for /healthz

GET Request

#without payload
curl -vvvv http://localhost:3307/healthz

#with payload
curl -X GET http://localhost:3307/healthz -H "Content-Type: application/json" -d '{"name": "Rama Raju"}'

PUT Request check for 405

#without payload
curl -vvvv -XPUT http://localhost:3307/healthz

#with payload
curl -X PUT 'http://localhost:3307/healthz' -H 'Content-Type: application/json' -d '{"name": "Rama Raju"}'

POST Request check for 405

#without payload 
curl -X POST 'http://localhost:3307/healthz'

#with payload
curl -X POST 'http://localhost:3307/healthz' -H 'Content-Type: application/json' -d '{"name": "Rama Raju"}'

DELETE Request check for 405

curl -X DELETE 'http://localhost:3307/healthz'

PATCH Request check for 405

#without payload
curl -X PATCH 'http://localhost:3307/healthz'

#with payload
curl -X PATCH 'http://localhost:3307/healthz' -H 'Content-Type: application/json' -d '{"name": "Rama Raju"}'

Query Parameters Check

curl -X GET 'http://localhost:3307/healthz?name=ram&neuid=003'

Unit Test using jest

npm test

Stop the mysql process

sudo pkill mysqld

Restart the mysql process

sudo /usr/local/mysql/support-files/mysql.server restart

User Creation (POST)

/v1/user

Get & put for authenticated users only

/v1/user/self

Webapp Demo on Centos

SCP the ziped application code to centos

scp -i /path/to/your-ssh-private-key /path/to/your-file.zip centos@droplet-ip:/root

SSH into the centos machine

#change the key permission
chmod 600 /path/to/your-private-key 

# ssh using private key
ssh -i /path/to/your-private-key root@droplet-ip

Unzip the application & install mysql

sudo dnf install unzip
unzip path/to/your-file.zip
# create the dotenv file for your app in the vm
# install mysql
sudo yum install wget

sudo wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

sudo rpm -Uvh mysql80-community-release-el7-3.noarch.rpm

sudo yum install mysql-server

sudo systemctl start mysqld

sudo systemctl enable mysqld

# give your db credentials
sudo mysql_secure_installation

mysql --version

mysql -u root -p

Install node js

curl -sL https://rpm.nodesource.com/setup_16.x | sudo bash -

sudo yum install -y nodejs

node --version

Note :

Enable port on which your application runs & give ssh access only to your ip in firewall settings of ypur vm

query the table..

SELECT * FROM restapi.Users;

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 81.2%
  • Shell 15.6%
  • HCL 3.2%