Coder Social home page Coder Social logo

northcoders_news_backend's Introduction

Northcoders News

Northcoders News is a Reddit-style website with a RESTful API. It has a database of articles created by users, with functionality to add comments to articles and to up or down vote all articles and comments.

Click here to view all API endpoints.

Getting Started

Prerequisites

  • Node.js
  • MongoDB

Fork the repo and clone:

git clone https://github.com/liz-a/Northcoders_News_Backend.git

Navigate into folder and install dependencies:

npm install

Create a config folder at at root level, with config files as below:

mkdir config
touch config/index.js
touch config/development.js
touch config/production.js
touch config/test.js

Config file content examples:

  • index.js:
process.env.NODE_ENV = process.env.NODE_ENV || 'development';

module.exports = require(`./${process.env.NODE_ENV}`);
  • development.js:
module.exports = {
    DB: 'mongodb://localhost:27017/northcoders_news',
    PORT: 9090
}
  • production.js:
module.exports = {
    DB: 'mongodb://user:insert_your_mlab_password_here.mlab.com:27459/northcoders_news'
}
  • test.js:
module.exports = {
    DB: 'mongodb://localhost:27017/northcoders_news_test',
    PORT: 9090
}

Start MongoDB in a new terminal:

mongod

Seed the database:

npm run seed:dev

Run the development server:

npm run dev

In the browser or Postman navigate to: localhost:9090/api, this will serve a set of instructions for navigating to endpoints.

Install Postman to submit post requests: https://www.getpostman.com

Running the tests

Tests use Chai, Supertest and Mocha. If you wish to view the test files open spec/index.spec.js

Test descriptions provided for each test will show when npm test is run.

npm test

API Endpoints

Return all topics.

GET /api/topics

Returns all articles of a given topic.

GET /api/topics/:topic/articles

Returns all articles.

GET /api/articles

Returns comments for a given article.

GET /api/articles/:article_id/comments

Adds a comment to the database. This route requires a JSON body with a comment key value pair eg {"comment": "Things I want to say"}

POST /api/articles/:article_id/comments

Increases or decreases the vote count of a given article by one. This route requires a vote query of 'up' or 'down'.

PUT /api/articles/:article_id

Increases or decreases the vote count of a given comment by one. This route requires a vote query of 'up' or 'down'.

PUT /api/comments/:comment_id

Returns the deleted comment and confirmation that comment has been deleted.

DELETE /api/comments/:comment_id

Returns all users.

GET /api/users/

Returns all articles by the specified user.

GET /api/users/:username/articles

Built With

Author

Liz Ardolino

northcoders_news_backend's People

Contributors

sssam-c avatar harrietty avatar

Watchers

James Cloos avatar Liz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.