https://daily-newsy.herokuapp.com/api
This api has many endpoints allowing access to northcoders news.
Clone this repo:
git clone https://github.com/anisapatel/be-nc-news.git
cd be-nc-news
Install the dependencies:
npm i
Set up the development and test databases:
npm run setup-dbs
Seed the development databases:
npm run seed
Run the app. It will run on http://localhost:9090:
npm start
To view all the avaialable end points in JSON format, make a GET /api request.
The following endpoints are available:
GET /api/topics
GET /api/users/:username
GET /api/articles/:article_id
PATCH /api/articles/:article_id
POST /api/articles/:article_id/comments
GET /api/articles/:article_id/comments
GET /api/articles
PATCH /api/comments/:comment_id
DELETE /api/comments/:comment_id
GET /api
GET /api/topics
- an array of topic objects, each of which should have the following properties:
slug
description
GET /api/users/:username
- a user object which should have the following properties:
username
avatar_url
name
GET /api/articles/:article_id
-
an article object, which should have the following properties:
author
which is theusername
from the users tabletitle
article_id
body
topic
created_at
votes
comment_count
which is the total count of all the comments with this article_id - you should make use of knex queries in order to achieve this
PATCH /api/articles/:article_id
-
an object in the form
{ inc_votes: newVote }
newVote
will indicate how much thevotes
property in the database should be updated by
e.g.
{ inc_votes : 1 }
would increment the current article's vote property by 1{ inc_votes : -100 }
would decrement the current article's vote property by 100
- the updated article
POST /api/articles/:article_id/comments
- an object with the following properties:
username
body
- the posted comment
GET /api/articles/:article_id/comments
- an array of comments for the given
article_id
of which each comment should have the following properties:comment_id
votes
created_at
author
which is theusername
from the users tablebody
sort_by
, which sorts the comments by any valid column (defaults to created_at)order
, which can be set toasc
ordesc
for ascending or descending (defaults to descending)
GET /api/articles
- an
articles
array of article objects, each of which should have the following properties:author
which is theusername
from the users tabletitle
article_id
topic
created_at
votes
comment_count
which is the total count of all the comments with this article_id - you should make use of knex queries in order to achieve this
sort_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)author
, which filters the articles by the username value specified in the querytopic
, which filters the articles by the topic value specified in the query
PATCH /api/comments/:comment_id
-
an object in the form
{ inc_votes: newVote }
newVote
will indicate how much thevotes
property in the database should be updated by
e.g.
{ inc_votes : 1 }
would increment the current comments's vote property by 1{ inc_votes : -1 }
would decrement the current comments's vote property by 1
- the updated comment
DELETE /api/comments/:comment_id
- delete the given comment by
comment_id
- status 204 and no content
GET /api
- JSON describing all the available endpoints
- Node.js v13.2.0
- Express.js
- PostgreSQL
- Node postgres
- Knex v0.20.8
- Mocha v7.0.0
- Chai v4.2.0
- Chai-sorted v0.2.0
- SuperTest v4.0.2
- pg v7.17.1
- nodemon v2.0.2