37
loading...
This website collects cookies to deliver better user experience
client — which contains the front-end code built with React.js, and
server — which has the backend developed using Express.js
cd server
npm install
cd client
npm install
psql -U postgres
postgres
as password.create database yelp;
\c yelp
restaurants
tableCREATE TABLE restaurants (
id BIGSERIAL NOT NULL PRIMARY KEY,
name VARCHAR(50) NOT NULL,
location VARCHAR(50) NOT NULL,
price_range INT NOT NULL check(
price_range >= 1
AND price_range <= 5
)
);
reviews
CREATE TABLE reviews (
id BIGSERIAL NOT NULL PRIMARY KEY,
restaurant_id BIGINT REFERENCES restaurants(id) ON DELETE CASCADE,
name VARCHAR(50) NOT NULL,
review TEXT NOT NULL,
rating INT NOT NULL check(
rating >= 1
AND rating <= 5
)
);
restaurants
table.INSERT INTO restaurants(name, location, price_range)
VALUES ('Iya Toyosi Canteen', 'Sagamu', 3);
server
folder and create a .env
file. Add the following contents.PG_USER=postgres
PG_PASSWORD=postgres
PG_HOST=localhost
PG_PORT=5432
PG_DATABASE=yelp
PORT=7000
npm start
npm start
Visit Heroku and create an account if you don’t have one.
Install the Heroku CLI.
Open your terminal and run the heroku login
command after installing the CLI. To complete your login, you will be prompted to enter any key to navigate your web browser. The CLI will then automatically log you in.
Create a new Heroku app
heroku create
heroku create your-app-name
heroku addons:create heroku-postgresql:hobby-dev --app your-app-name
heroku addons
to check the new addon you just created. You will see the Postgres database created with a name generated automatically, for example postgresql-pointy-04867
nameless-journey-88760 postgresql-pointy-04867 heroku-postgresql:hobby-dev free created
heroku pg:psql database-name --app your-app-name
server/config/db.sql
to create the two tables and insert a row.Don’t forget to replace the database name and app name with your own Heroku info.
heroku local web
heroku git:remote -a alluring-bryce-canyon-75245
alluring-bryce-canyon-75245
with anything, preferable your Heroku app name. git subtree push --prefix server heroku main
Go to the Heroku dashboard and choose the app you are working on
Click on the Settings tab. You will see the Config Vars section. Click on reveal vars.
Set the input with placeholder KEY with PROJECT_PATH
and the input with placeholder VALUE with server
and click on Add.
Still on the Settings tab, you must add a Buildpack that instructs Heroku to locate your folder.
Under the Config Vars section, you will see the Buildpack section. Click on add Buildpack and enter https://github.com/timanovsky/subdir-heroku-buildpack.git as the URL. Save changes.
Go to the deploy tab. From the deployment method, choose GitHub.
Search and connect the Github repo.
Finally, enable automatic deployment.
git push
, the server will deploy automatically. You don’t have to run the below command anymore.git subtree push --prefix server heroku main
client/src/apis
. Open the RestaurantFinder.js
file.Go to Netlify and login into your account. Create if you don’t have one.
After logging in, click on the button new site from git
Choose your git provider.
Choose the repository you want to deploy.
Under Basic Build Settings, fill the inputs as below.
Click on Deploy site.
After deploying successfully, you will see a link to preview the app.
git push
, automatic deployment will start for both Heroku(server) and Netlify(client).