- Install
node.jswith version 17.3.1 - Install postgresql
- Set up a postgresql user
- Run
yarn install - Run
yarn dev - Go to
http://localhost:3000 - Data can be exported to csv by visiting
http://localhost:3000/export
- Set up a free ARM server on Oracle Cloud
- Open ingress port
80
- Open ingress port
- Connected to the subdomain homework.yxwu.me to the server by adding DNS A and AAAA records
- Open ingress port
80on the server withiptables -I INPUT 6 -m state --state NEW -p tcp --dport 80 -j ACCEPT - Set up nodejs on the server with
apt install node - Initialized a new JavaScript project with
yarn init .inside my project folder - Created a git repository on Github
- Associated my local project with the git repository
git initgit add .git config --global user.email "[email protected]"git config --global user.name "Yixuan"git commit -m "first commit"git branch -M maingit remote add origin https://github.com/yixuanwu4/data-collection.gitgit push -u origin main
- Added
expressto the project withyarn add express - Added a
.gitignorefile generated by gitignore.io - Implemented
index.html,style.css, andform.html, and updated to the git repository. - Setup postgresql database
- Install postgresql database on the server with
sudo apt install postgresql - Log into database with
sudo -u postgres psql - Create new database for this project
CREATE DATABASE datacollection; - Create a new user
CREATE USER yixuan WITH ENCRYPTED PASSWORD 'kittysMakeMeHappy'; - Grant permissions to user for new database
GRANT ALL PRIVILEGES ON DATABASE datacollection TO yixuan; - Create a new table with the header names (see the command in file tables.sql)
- Insert a row into the created table (see the command in file tables.sql)
- Install postgresql database on the server with
- Implemented backend in server.js.
- Start server in production mode
yarn prod &(prod is defined in package.json) - From pg-copy-streams import copyTo to copy the data out of PostgreSQL and save it into export.csv.