NC Noose is a social news aggregation, web content rating, and discussion website. Think something along the lines of Reddit.
NC Noose has articles which are divided into topics. Each article has user curated ratings and can be voted up or down. Users can add or delete comments on an article. Comments can also be voted up or down.
The database is implemented in PSQL, and populated & queried using Knex.
FRONT-END DEMO https://nc-noose.netlify.com/
FRONT-END REPO https://github.com/philval/nc-noose-front-end
BACK-END DEMO https://nc-noose.herokuapp.com/api/articles
BACK-END REPO https://github.com/philval/nc-noose-back-end
-
A local installation of Node (latest)
-
a heroku account if deployed
-
Postgres App for OSX. Download from https://postgresapp.com/ and follow the instructions.
-
a knexfile.js file in the project root folder as below. DB_URL is the production DB URL sourced via heroku config:get (see package.json).
const ENV = process.env.NODE_ENV || 'development';
const { DB_URL } = process.env;
const config = {
development: {
client: 'pg',
connection: {
database: 'db_knews_dev',
},
migrations: {
directory: './db/migrations',
},
seeds: {
directory: './db/seeds',
},
},
test: {
client: 'pg',
connection: {
database: 'db_knews_test',
},
migrations: {
directory: './db/migrations',
},
seeds: {
directory: './db/seeds',
},
},
production: {
client: 'pg',
connection: `${DB_URL}?ssl=true`,
migrations: {
directory: './db/migrations',
},
seeds: {
directory: './db/seeds',
},
},
};
module.exports = config[ENV];
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
-
Clone the repo from git : https://github.com/philval/BE2-NC-Knews
-
Run : npm install
-
To drop the Postgres dev & test databases (if they exist) and create new ones : npm run setup:dbs
-
To seed the dev database : npm run seed
-
To start the app : npm run dev
-
The api is exposed at http://localhost:9090/
-
Example : enter this URL into your browser : http://localhost:9090/api/articles
To run the tests : npm run test
This changes the NODE_ENV to test, and re-seeds the database with test data - before running each test - as specified in db.spec.js
To do.
This project is licensed under the MIT License - see the LICENSE.md file for details
GET /api/topics
- an array of topic objects, with the following properties:
slug
description
POST /api/topics
- an object containing the following properties:
slug
which is uniquedescription
- the posted topic object
GET /api/articles
- an
articles
array of article objects, each of which has 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
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)
POST /api/articles
- an object containing the following properties:
title
body
topic
username
- the posted article
GET /api/articles/:article_id
- an article object, which has 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
PATCH /api/articles/:article_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 }
will increment the current article's vote property by 1{ inc_votes : -1 }
will decrement the current article's vote property by 1
- the updated article
DELETE /api/articles/:article_id
- delete the given article by
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
which is theusername
from the users tablebody
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)
POST /api/articles/:article_id/comments
- 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 }
will increment the current article's vote property by 1{ inc_votes : -1 }
will decrement the current article'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/users
- an array of user objects, each of which has the following properties:
username
avatar_url
name
POST /api/users
- an object containing the following properties:
username
avatar_url
name
- the posted user
GET /api/users/:username
- a user object which has the following properties:
username
avatar_url
name
GET /api
- JSON describing all the available endpoints on the API