Clone the repository at any path
git clone https://github.com/tamiat/backend.git
cd backend
Create postgresql database and set password for postgres user
sudo -i -u postgres
psql
CREATE DATABASE <database_name>;
ALTER USER postgres WITH PASSWORD '<new_password>';
(Optional) you can use the following instructions to create the database with a different user:
sudo -u postgres psql postgresCREATE ROLE <username> LOGIN PASSWORD 'new_password';CREATE DATABASE <database_name> WITH OWNER = <username>SHOW port this gives you the DBPORT
type exit twice to return to the terminal.
At backend directory rename .env.example file to .env
mv .env.example .env
This file contains all necessarily environment variables.
Environment Variable
Explanation
HOST
ex: localhost
DBNAME
database name
DBPASS
database password
DBPORT
database port, set to 5432
PORT
which port number to use for endpoints, ex: 8080
DBUSER
database user, ex: postgres
JWT_SECRET
string to set secret of jwt
EMAIL_SENDER
the email that will send confirmation emails to users. It should be activated in sendgrid profile
TEMPLATE_ID
which template id sendgrid uses as a format to send emails
SENDGRID_API_KEY
api key associated with the sender account
Sendgrid is a thirdparty we use to send emails
Set environment variables using your preferred text editor
Back to backend directory, run:
go get github.com/gobuffalo/pop/...
Edit ~/.profile and add this line into it.
export PATH=$PATH:~/go/bin
Run the following command to apply changes to .profile
source ~/.profile
Run the following command
which soda
It should give output like this:
/home/<user_name>/go/bin/soda
Now run the following to create all database tables
soda migrate up