Skip to content

chris-butterworth/cb-news

Repository files navigation

CB News API

Introduction

CB News is a RESTful API for the purpose of accessing application data programmatically, mimicking a real world backend service (such as Reddit) which should provide this information to the front end architecture. See it live here! The API uses the Express Node.js web application framework and interacts with the PSQLdatabase using node-postgres.

Project Features

  • GET Topics, Articles and Comments
  • POST new Comments to an Article
  • PATCH existing Articles and Comments
  • DELETE comments
  • Articles and Comments can be up or down voted

Installation Guide

  • Find the repository here
  • Install and run the Postgres app.
  • Clone using git clone https://github.com/chris-butterworth/cb-news
  • The main branch is the current working version of the API
  • Run npm install to install all dependencies
  • Create two .env files in your project root folder .env.test and.env.development Into each, add PGDATABASE= with the correct database name for that environment (see /db/setup.sql for the database names).
  • Run npm run setup-dbs to seed the databases

Minimum version - Node.js v20.5.1, Postgres v15

Usage

  • Run npm test app to run tests

API Endpoints

HTTP Verbs Endpoints Action
GET /api Responds with a list of available endpoints
GET /api/topics Responds with a list of topics
GET /api/articles Responds with a list of articles. Accepts queries ‘sort_by’ ‘order’ and ‘topic’
POST /api/articles Adds a new article
GET /api/articles/:article_id Responds with a single article by article_id
PATCH /api/articles/:article_id Used to add votes to an article by article_id
GET /api/articles/:article_id/comments Responds with a list of comments by article_id
POST /api/articles/:article_id/comments Add a comment by article_id
PATCH /api/articles/:article_id/comments Used to add votes to a comment by comment_id
DELETE /api/comments/:comment_id Deletes a comment by comment_id
GET /api/users Responds with a list of users
GET /api/users/:username Responds with a single user

Technologies Used

  • NodeJS This is a cross-platform runtime environment built on Chrome's V8 JavaScript engine used in running JavaScript codes on the server. It allows for installation and managing of dependencies and communication with databases.
  • ExpressJS This is a NodeJS web application framework.
  • PostgreSQL~ is an advanced, enterprise class open source relational database that supports both SQL (relational) and JSON (non-relational) querying.

Authors

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 23