A robust Node.js application designed to efficiently test for various Purpose. Utilizing Express for the backend, MySQL for database management, and React for the frontend interface, this system facilitates CRUD operations with seamless CORS handling and environment variable management.
Client: React, Bootstrap
Server: Node, Express
Database: MYSQL
Before installing check Nodejs preferred Node Version v22.2.0
on your system, MYSQL Database (if using local)
git clone https://github.com/soocrates/Node_React_CRUD.git
cd Node_React_CRUD
File Structure: After cloning you see frontend
and backend
directory and overall project will look like this
soocrates@ubuntu:~/Node_React_CRUD $ tree -L 2
├── backend
│ ├── connection.js
| ├── .env.sample
│ ├── index.js
│ ├── package.json
│ ├── package-lock.json
│ └── secret_manager.js
├── db.sql
├── frontend
│ ├── dist
│ ├── index.html
│ ├── package.json
│ ├── package-lock.json
│ ├── public
│ ├── src
│ └── vite.config.js
└── README.md
Create a .env
file inside backend
directory of your project from .env.sample
:
APP_PORT=3000
### DB_HOST could be remote host, proxy or localhost URL but must me mysql
DB_HOST= env-example-db.cfasdfasr34dsadc4.us-east-1.rds.amazonaws.com
DB_PORT=3306
DB_NAME=test_db
### From where you want use Credentials
# Options Could be
# 1. from_secret (to pass creds from aws secret)
### 2. from_env (to pass creds from env)
CRED= from_secret
### If you are Passing Credentials Directly from ENV
DB_USER= test_user
DB_PASSWORD= test_0000
### If you are using AWS Secret Manager
AWS_REGION = us-east-1
AWS_SECRET_NAME = test-secret-manager
cd Node_React_CRUD
cd backend
npm install
node app.js
cd Node_React_CRUD
cd frontend
npm install
npm start
- URL:
/students
- Method:
GET
- Response: JSON array of student records
- URL:
/student/:id
- Method:
GET
- Response: JSON object of the student record
- URL:
/create
- Method:
POST
- Request Body:
{
"name":"Student Name",
"dob":"YYYY-MM-DD",
"result":"Pass/Fail"
}
- Response: Success or error message
- URL:
/update/:id
- Method:
PUT
- Request Body:
{
"name":"Updated Student Name",
"dob":"YYYY-MM-DD",
"result":"Pass/Fail"
}
- Response: Success or error message
- URL:
/delete/:id
- Method:
DELETE
- Response: Success or error message
sudo apt update && sudo apt upgrade && sudo apt autoclean && sudo apt autoremove
sudo apt install nodejs@latest
sudo apt install npm
## for Process management
sudo npm install pm2@latest -g
## for mysql
sudo apt install mysql-server mysql-client
## for mariadb
sudo apt install mariadb-server mariadb-clieant
cd Node_React_CRUD/backend
pm2 start index.js --name="backend-api"
express
: Web framework for Node.jsmysql
: MySQL client for Node.jscors
: Middleware for handling Cross-Origin Resource Sharingdotenv
: Module to load environment variables from a.env
file
react
: JavaScript library for building user interfacesaxios
: Promise-based HTTP client for the browser and Node.jsreact-router-dom
: DOM bindings for React Router
Contributions are welcome Please feel free to submit a pull request or open an issue if you encounter any problems. Appsec and Build Spec are yet to be uploaded Thank you #