Northcoders (NC) News API is a project built for the purpose of accessing application data programmatically. The intention is to mimic the building of a real world backend news service (such as reddit) which should provide this data to the front end architecture. The API is hosted through Azure App Service.
To take a look at the API endpoints and view them in action click here.
- Built with
- Installation
- Setting up environment variables
- Seeding the database
- Running tests with Jest
- Complete list of endpoints
The technologies and packages used for this project are listed below:
- node.js v14.17.4 LTS
- postgreSQL v13.0.0
Project dependencies:
Dev dependencies:
- jest v27.06
- jest-sorted v1.0.12
- supertest v6.1.4
To run the API locally you will need to follow the steps below:
- Ensure that you have installed:
- Fork and Clone the repo
- Open the repo and install the dependencies by running:
npm install
Optional
- In order to run the tests install the following dev dependencies:
npm install -D jest jest-sorted supertest
- Run tests:
npm test
You will need to create two .env files for this project:
.env.test containing:
DBNAME=nc_news_test
.env.development containing:
DBNAME=nc_news
Make sure that these .env files are .gitignored.
Firstly, set up the database by running:
npm run setup-dbs
Next, set up the connection the database and seed the databases with the data by running:
npm run seed
To get a further insight into the seeding of the database you can look in the seed.js file which contains information on the table structures, data types and foreign key references.
See below for a complete list of endpoints that are accessible on the server. Alternatively an overview of endpoints, descriptions and examples are provided on the /api endpoint.
GET /api
GET /api/topics
GET /api/articles
GET /api/articles/:article_id
PATCH /api/articles/:article_id
GET /api/articles/:article_id/comments
POST /api/articles/:article_id/comments
PATCH /api/comments/:comment_id
DELETE /api/comments/:comment_id
GET /api/users
GET /api/users/:username
GET /api/articles/1
"article": {
"article_id": 1,
"author": "butter_bridge",
"body": "I find this existence challenging",
"created_at": "2020-07-09T20:11:00.000Z",
"title": "Living in the shadow of a great man",
"topic": "mitch",
"votes": 100,
"comment_count": "13"
}