Note
This is a full stack project. The frontend repository for this project can be found here: https://github.com/captainharrie/nc-news-frontend.
A demo version of the API is hosted at https://htpncnews.onrender.com/api.
Warning
The first request you make to the API may take a minute or so to resolve as the demo server spins up. The server will spin down if there haven't been any requests to the API in the last 15 minutes. After the server starts, there shouldn't be any more delays.
NC News is a RESTful API for a news website backend. Some features include:
- Fetch all articles and optionally filter and sort the results.
- Fetch all topics
- Fetch all users
- Fetch all comments for an article by ID
- Get an article by ID
- Vote on an article by ID
- Create & delete comments
Written in Node.js utilising Express.js and Node-Postgres, it utilises TDD & MVC in the functional programming paradigm to create various endpoints for GET, POST, DELETE, and PATCH requests to perform CRUD operations on a database.
Ensure you have Postgres 16.6+ and Node.js v23.3.0+ installed on your machine. Instructions for installing PSQL on your machine here, and for Node.js can be found here.
- Clone the repository to your local machine using
git pull https://github.com/captainharrie/NC-news.git
- Create your .env files.
Important
- You will need to set up two files in the root directory,
.env.development
and.env.test
, pointing thePGDATABASE
variable to your development and test databases respectively. View the.env-example
file for an example of what these files should look like, and the./db/setup.sql
file for the expected database names. - If you have a production database set up, you can also create a
.env.production
file, pointing theDATABASE_URL
variable to your remote database. - Ensure that these new files are all ignored in
.gitignore
!
- Open the repository directory in your terminal and enter the following command:
npm install
. This will install all the project dependencies. - Once complete, run the following commands in order:
npm run setup-dbs
,npm run seed
,npm run test
. If everything has been set up correctly, you should see all the tests run and pass successfully.
This portfolio project was created as part of a Digital Skills Bootcamp in Software Engineering provided by Northcoders