This News API provides a REST API that enables users to search for and retrieve information on topics, articles, users, and comments from a database.
It is hosted on Render and can be viewed here: NEWS API Note: The API is hosted on a free-tier plan, which may result in longer initial load times as the server spins up
- PostgreSQL v13.5
- Node.js v14.18.1 and above
- Clone this repository
git clone https://github.com/reemhd/News-API.git
- Install the dependencies:
npm install
npm install pg
npm install dotenv
npm install express
- To connect the two databases, you need to create two files that allow access to environment variables. These files should contain the following lines:
- .env.test --> PGDATABASE=nc_news_test
- .env.development --> PGDATABASE=nc_news
- Seed Databases:
npm run setup-dbs
npm run seed
npm run seed-prod
- To run tests you will need development dependencies installed:
npm install supertest -D
npm install jest -D
npm install jest-sorted -D
npm install pg-format -D
- To run tests:
npm test
GET /apiResponds with all the available endpoints
GET /api/topicsGet all the topics
POST /api/topicsPost topics
GET /api/articlesReturns all the articles
GET /api/articles/:article_idReturns a specific article
POST /api/articles/:article_idPost a specific article
PATCH /api/articles/:article_idUpdate a specific article's votes
DELETE /api/articles/:article_idDeletes a specific article
GET /api/articles/:article_id/commentsGets all the comments for the specific article
POST /api/articles/:article_id/commentsPost a comment for a specific article
DELETE /api/comments/:comment_idDeletes a comment
PATCH /api/comments/:comment_idUpdates a comment's votes
GET /api/usersReturns all users
GET /api/users/:usernameReturns a specific user
Database was set up on ElephantSQL
Hosted on Render