This API will power the frontend of my NC News app. NC News will be a reddit-style app with users/topics/articles/comments.
Clone the project
git clone https://github.com/thatrussguy/russ-nc-news.git
Install dependencies
npm install
Set up databases
npm run setup-dbs
Seed database
npm run seed
Start the app locally
npm run start
The app should now running on http://localhost:9090
Make a http GET request to /api for endpoint descriptions
The following endpoints are available
GET /api
- JSON describing all available endpoints
GET /api/topics
- an array of topic objects, each of which has the following properties:
slug
description
POST /api/topics
- an object with the following properties:
slug
description
- the posted topic
GET /api/articles
- an
articles
array of article objects, each of which has the following properties:author
title
article_id
topic
created_at
votes
comment_count
- a
total_count
property which is the total matched articles ignoring limit
author
, which filters the articles by the username value specified in the querytopic
, which filters the articles by the topic value specified in the querysort_by
, which sorts the articles by any valid column (defaults to date)order
, which can be set toasc
ordesc
for ascending or descending (defaults to descending)limit
, which limits the number of articles returnedp
, which specifies what page of results to return
POST /api/articles
- an object with the following properties:
title
body
topic
author
- the posted article
GET /api/articles/:article_id
- an article object, which should has the following properties:
author
title
article_id
body
topic
created_at
votes
comment_count
PATCH /api/articles/:article_id
-
an object in the form
{ inc_votes: newVote }
newVote
indicates how much thevotes
property in the database will be updated by
e.g.
{ inc_votes : 1 }
increments the current article's vote property by 1{ inc_votes : -100 }
decrements the current article's vote property by 100
- the updated article
DELETE /api/articles/:article_id
- delete article
article_id
- status 204 and no content
GET /api/articles/:article_id/comments
- an array of comments for the given
article_id
of which each comment has the following properties:comment_id
votes
created_at
author
body
sort_by
, which sorts the articles by any valid column (defaults to created_at)order
, which can be set toasc
ordesc
for ascending or descending (defaults to descending)limit
, which limits the number of articles returnedp
, which specifies what page of results to return
POST /api/articles/:article_id/comments
Request body accepts
- an object with the following properties:
username
body
- the posted comment
PATCH /api/comments/:comment_id
-
an object in the form
{ inc_votes: newVote }
newVote
will indicate how much thevotes
property in the database will be updated by
e.g.
{ inc_votes : 1 }
increments the current comment's vote property by 1{ inc_votes : -1 }
decrements the current comment's vote property by 1
- the updated comment
DELETE /api/comments/:comment_id
- delete comment
comment_id
- status 204 and no content
POST /api/users
- an object with the following properties:
username
avatar_url
name
- the posted user
GET /api/users
- a
users
array of user objects, each of which has the following properties:username
avatar_url
name
GET /api/users/:username
- a user object which has the following properties:
username
avatar_url
name