Skip to content

captainharrie/NC-News-Backend

Repository files navigation

Northcoders News API

northcoders jest Node express postgres

Note

This is a full stack project. The frontend repository for this project can be found here: https://github.com/captainharrie/nc-news-frontend.

Live Demo

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.

About the Project

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.

Setup

Prerequisites:

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.

Instructions:

  1. Clone the repository to your local machine using git pull https://github.com/captainharrie/NC-news.git
  2. Create your .env files.

Important

  • You will need to set up two files in the root directory, .env.development and .env.test, pointing the PGDATABASE 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 the DATABASE_URL variable to your remote database.
  • Ensure that these new files are all ignored in .gitignore!
  1. Open the repository directory in your terminal and enter the following command: npm install. This will install all the project dependencies.
  2. 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published