Hi! Welcome to my Echo Chamber API project!
The hosted version of this API can be found at https://be-echo-chamber.herokuapp.com/api
This project is inspired by the popular discussion site Reddit, and aims to emulate it's back end, with implementation and consideration of the following:
- Building RESTful APIs and data transfer.
- Using a Node.js Web Server App.
- PostGresSQL databases and Express servers.
- MVC architecture.
- Test Driven Development.
- Error handling.
It is written using:
- Node.js
- Express as web server app framework.
- postGresSQL for building the database.
- Node-PG for interacting with postGres.
- Jest, jest-sorted & supertest for TDD.
- Github and Heroku for git version control and hosting.
You will need to have the following packages installed to download and work with this project:
- Node.js v16.8.0 - Install instructions Here
- postGreSQL v12.8, server 10.18 - Install instructions Here
- A code editor such as VSCode
- To get started, navigate to the directory of your choice and run this shell command in your terminal:
git clone https://github.com/JamesWall-hub/be-echo-chamber.git
You will be asked to enter your git login details and access token.
- Open the repo folder in your code editor of choice and run the following commands in the terminal:
npm install
npm install --dev
This will install all node packages required for normal running of the repo, including devDependencies such as the testing modules.
- To set up the development and testing databases run this command:
npm run setup-dbs
This will create the databases nc_news
and nc_news_test
in your local instance of PostgreSQL
- Next, you will need to create two
.env
files to ensure the right database is seeded when a development or test script is run. In the root directory of the repo, create the following two files:
-
.env.development
:edit the file to add this single line:
PGDATABASE=nc_news
-
.env.test
:edit the file to add this single line:
PGDATABASE=nc_news_test
- Once these files have been created, running the seed script will populate our development database! Run the following command:
npm run seed
- Run the following command to view the test suite located in
__tests__/app.test.js
:
npm test app