This API is used to interact with the nc-news SQL database. You can get articles, comments, users and topics, query by topics, post comments and patch articles, and delete comments using different endpoints (see /api endpoint for a json representation of all the available endpoints).
The hosted version of this API can be found here: https://hollycr-nc-news.onrender.com/api
You can use a local version of this API by doing the following:
-
Make sure you have Node.js (min. v17.0.29) and PostgreSQL (min. v14.10) installed. The following instructions also assume the use of NPM (Node Package Manager) to manage our project dependencies.
-
Clone this repo locally using the command
git clone https://github.com/hollycr/be-nc-news
-
Install dependencies by navigating to the root directory and running
npm i
. -
In order to run this project locally, you must create two .env files,
.env.test
and.env.development
in order to connect to the two databases locally. Within these files, set yourPGDATABASE=nc_news_test
andPGDATABASE=nc_news
respectively. (Ensure these.env
files are included in your.gitignore
file.) -
To set-up and seed local database, run
npm run setup-dbs
and thennpm run seed
.
Now you're ready to use the API!
To run the server with the development database, use the command npm start
. To run tests (which will use the test database) use npm test
. There are two test files located in __tests__
and you can specify npm test app
to only run app.test.js
or npm test utils
to only run utils.test.js
.