Welcome to the NC News API! This is the backend API for the NC News project, built with Node.js, Express, and PostgreSQL. It provides endpoints for accessing articles, comments, topics, and users, and is designed to be fast, reliable, and easy to use.
The API is hosted on Render. You can explore it here:
👉 https://backend-news-project-mdgt.onrender.com/api
The NC News API powers a news aggregation platform, similar to Reddit. It allows users to:
- Read articles and comments.
- Post new comments.
- Vote on articles.
- Filter and sort articles by topic, date, or popularity.
The API is built with a focus on RESTful principles and includes features like:
- Filtering: Articles can be filtered by topic.
- Sorting: Articles can be sorted by any valid column (e.g.
created_at
,votes
). - Pagination: Coming soon!
Follow these steps to set up the project locally.
- Node.js: Minimum version 18.x
- PostgreSQL: Minimum version 14.x
Clone the repository:
git clone https://github.com/SchubertAlex/nc-news-project.git
Navigate to the project directory:
cd nc-news-project
Install dependencies:
npm install
Create two .env
files for your environment variables:
.env.development
withPGDATABASE=<your_development_database_name>
.env.test
withPGDATABASE=<your_test_database_name>
Replace <your_development_database_name>
and <your_test_database_name>
with the names of your local development and test databases.
Run the following commands to set up and seed the databases:
npm run setup-dbs
npm run seed
To start the server in development mode, run:
npm run dev
The server will be available at http://localhost:9090.
To run the test suite, use the following command:
npm test
GET /api/articles
GET /api/articles/1
GET /api/articles/1/comments
POST /api/articles/1/comments
{
"username": "butter_bridge",
"body": "This is a new comment."
}
PATCH /api/articles/1
{
"inc_votes": 10
}
DELETE /api/comments/1
The project requires two .env
files for environment variables:
PGDATABASE=<your_development_database_name>
PGDATABASE=<your_test_database_name>
These files are used to connect to the development and test databases, respectively.
- Node.js: Runtime environment.
- Express: Web framework for building the API.
- PostgreSQL: Database for storing articles, comments, and users.
- Render: Hosting platform for the live API.
Alex Schubert: GitHub | LinkedIn
This project was completed as part of the Northcoders Bootcamp in Software Development. Special thanks to my instructors and peers for their support and feedback!