https://nc-news-2yza.onrender.com/api
This is an API that simulates the backend service used on a news/article website. It is written using JavaScript, Node.js, Express.js, and uses PostgreSQL as a database. Endpoint testing is done using Jest and SuperTest. It supplies the following information:
-
articles
- shows a collection of articles
- shows a specific article, when an article id is given
- updates the vote count for a specific article
- posts a new article
- deletes an existing article
-
topics
- shows a collection of topics
- posts a new topic
-
comments
- shows a collection of comments for a specific article
- posts a new comment to a specific article
- deletes an existing comment
- updates the vote count for a specific comment
-
users
- shows a collection of users
- shows a specific user, when a username is given
-
Fork and clone this repository.
-
After cloning, you will need to create two .env files:
.env.test
and.env.development
. -
In each .env file, type in
PGDATABASE=<database_name_here>
, with the correct database name for each file. The database names can be found insetup.sql
. -
Make sure that the .env files are .gitignored.
-
Install dependencies by running
npm install
in your terminal. -
Setup the development and test databases by running the following scripts:
npm run setup-dbs
- creates the development and test databasesnpm run seed
- seeds the databasenpm run dev
- allows for your local server to listen out for requests
-
Make requests by using an API client, such as Insomnia, or you can open up your browser and type in
localhost:9090/[insert path here]
. The available endpoints can be found inendpoints.json
or here. -
Run
npm test
to run all tests.
node: v19.1.0
postgres: 8.7.3