Skip to content

TTibbs/be-nc-news

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

300 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Typing SVG

This is a backend server for a news application built with Express.js and PostgreSQL. The server provides API endpoints for managing news articles, topics, users, and comments. It supports CRUD operations and can be extended for various features such as user authentication, pagination, and more.

Live View

You can view the API live and view the endpoints that are available here

The frontend repository - the live demo can be seen here

Quick Tip:

For a better experience viewing JSON responses, install a browser extension like JSON Formatter

Table of Contents

Technologies Used

visual-studio-code-2019 git javascript

Installation

  1. Clone the repository:
git clone https://github.com/TTibbs/be-nc-news.git
cd be-nc-news
npm install

Set up the database:

Ensure you have PostgreSQL installed locally or use a hosted database such as Supabase.

If using Supabase:

  • Sign up at Supabase
  • Create a new project and retrieve your database URL.

Seed the database:

  • For development:
npm run seed
  • For production:
npm run seed-prod

Environment Variables

Set up the following .env files for different environments:

.env.development

PGDATABASE=your_development_database_name

.env.test

PGDATABASE=your_test_database_name

.env.production

DATABASE_URL=your_supabase_database_url

Notes:

  • PGDATABASE is for local development and testing.
  • DATABASE_URL is used in production (e.g., when deploying to Render).
  • Ensure .env.* is added to .gitignore to avoid exposing credentials.

Endpoints

Method Endpoint Description
GET /api Lists all available endpoints
GET /api/users Lists all users
GET /api/topics Lists all topics
GET /api/articles Lists all articles
GET /api/articles/:article_id View an article by its ID
GET /api/articles/:article_id/comments View comments on an article by its ID
POST /api/articles/:article_id/comments Creates a new comment on the article
PATCH /api/articles/:article_id Updates the votes on an article
DELETE /api/comments/:comment_id Deletes a comment by its ID

Running the Server and Seeding

You need to make sure you have these minimum versions of node.js and postgres in order for the project to run successfully:

  • Node.js ^22.5.1
  • Postgres ^14.13

To start the server:

npm run start

If you want to include more functionality and tests, you can run them with:

npm test
--- or shorthand
npm t

This portfolio project was created as part of a Digital Skills Bootcamp in Software Engineering provided by Northcoders

About

Express RESTful API server created as part of a Digital Skills Bootcamp in Software Engineering provided by Northcoders.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors