Welcome to the Article Hub API! It’s a simple and easy-to-use service for accessing news articles and related data. It’s hosted online here for anyone to use. (Please allow 1-2 minutes for the server to wake up)
This project is part of my portfolio whilst enrolled on the Northcoders Software Development Bootcamp.
The API provides access to a variety of news articles, allows for comments to be posted, and even lets you filter news by specific topics. It’s built using Node.js and Express and uses PostgreSQL for storing data and tested using Jest using the Test-Driven Development approach.
- Node.js
- Express
- PostgreSQL
- Jest & Supertest
- Node.js (v14.17.0 or newer)
- PostgreSQL (v11.18 or newer)
-
Clone the Project:
git clone https://github.com/RGBlife/news-api.git cd news-api
-
Install Dependencies:
npm install
-
Set up your Environments:
You will need to add the following environment variables to connect to the databases if you wish to clone the project and run it locally.
You’ll need to create two .env files: one for development (.env.development) and one for testing (.env.test). These should contain the variables needed for database connections.
Example files:
PGDATABASE=nc_news
PGDATABASE=nc_news_test
DATABASE_URL=your_database_url PORT=your_chosen_port
-
Setup the database and Populate:
npm run setup-dbs npm run seed
-
Run the Tests: Execute the test with the following command:
npm test
Check out what API endpoints are available and how to use them by going to API Info (I recommend installing the popular JDON viewer chrome extension that will display the JSON data in a more readable format.
The API has been created using the MVC design pattern and the database is stored on ElephantSQL and hosted using Render.