A Node.js Express web api used for Pisspricer. The api is currently deployed at pisspricer.co.nz/api/v1.
- Node.js
- npm
- Clone the repository.
git clone https://github.com/TooMuch4U/pisspricer-api
- Install npm dependencies.
# Change into the src directory cd api # Install npm dependencies npm install
- Set the following environment variables.
EMAIL_HOST= EMAIL_USER= EMAIL_PASSWORD= EMAIL_ADDRESS= CLOUD_SQL_CONNECTION_NAME= //see https://cloud.google.com/sql/docs/mysql/connect-app-engine-standard MYSQL_HOST=localhost MYSQL_USER=root MYSQL_PASSWORD=password MYSQL_DATABASE=pisspricer MYSQL_PORT=3306 IMAGE_BUCKET=images.pisspricer.co.nz BUCKET_KEY_PATH=/config/Pisspricer.json OPEN_PORT=4941
To enable https aswell as http...
- Set an
OPEN_PORT_HTTPS
environment variable to the desired https port. - Place the ssl certificate named
cert.pem
and the key namedkey.pem
in the directory (/api).
Start the api server with
npm start
A testing environment can be set up as described in the corresponding README files in
/testing-env
.
Export data: mysqldump -u root -p --databases pisspricer --routines > dump.sql
(optional) SCP mysqldump from gcloud compute instance: gcloud beta compute scp --zone "us-west1-b" --project "pisspricer" "instance-1":/containers/api/populate-data/dump.sql .
Move the dump.sql into the ./populate-data directory.
Start the docker container: sudo docker-compose up -d
Connect to the containers shell: sudo docker exec -it api_db_1 bash
Populate the data (takes 20 seconds): mysql -p < populate-data/dump.sql
A .env
needs to be created in the Docker directory.
A gcloud json key needs to be provided in the ./keys and specified in the .env file.