Coder Social home page Coder Social logo

alicw-be-nc-news's Introduction

Northcoders News API

This repository serves to provide very basic /api functionality to present information concerning a false news application, containing users, comments, articles & topics.

Endpoints provide basic functionality as well as more dynamic options where users can refine their searches by article_id, comment_id, topic, etc. Users can also structure returned queries by using sort_by or order_by options on certain endpoints.

The base link for the hosted api is below:

https://nc-news-acw.onrender.com

Endpoints

The numerous endpoints are listed here:

  1. GET /api (provides an in depth list of endpoint information)

    https://nc-news-acw.onrender.com/api/
  2. GET /api/topics (provides a list of article topics with a description & slug tag)

    https://nc-news-acw.onrender.com/api/topics
  3. GET /api/articles (provides all articles associated with the api)

    https://nc-news-acw.onrender.com/api/articles
  4. GET /api/articles?topic= (provides all articles associated with the given topic)

    https://nc-news-acw.onrender.com/api/articles?topic=coding
  5. GET /api/articles?sort_by= (provides all articles associated with the apo sorted by the given query)

    https://nc-news-acw.onrender.com/api/articles?sort_by=author
  6. GET /api/articles?sort_by=&order_by= (provides all articles associated with the apo sorted by the given query & ordered by another query)

    https://nc-news-acw.onrender.com/api/articles?sort_by=author&order_by=asc
  7. GET /api/articles/:article_id (provides a specific article by article_id)

    https://nc-news-acw.onrender.com/api/articles/3
  8. GET /api/articles/:article_id/comments (provides comments for the article_id provided)

    https://nc-news-acw.onrender.com/api/articles/3/comments
  9. GET /api/users (provides the username, name & avatar url for all users)

    https://nc-news-acw.onrender.com/api/users
  10. GET /api/articles?p= (provides the pagination for article listings)

    https://nc-news-acw.onrender.com/api/articles?p=1
  11. GET /api/articles/:article_id/comments?p= (provides the pagination for comments listings on single article pages)

    https://nc-news-acw.onrender.com/api/articles/:article_id/comments?p=1
  12. POST /api/articles/:article_id/comments (posts a comment on the associated article)

    https://nc-news-acw.onrender.com/api/articles/3/comments
  13. POST /api/users/signup (allows the user to sign up to the site - sign up is required to vote & comment)

    https://nc-news-acw.onrender.com/api/users/signup
  14. POST /api/users/login (allows the user to login to the site)

    https://nc-news-acw.onrender.com/api/users/login
  15. POST /api/articles (allows the user to add articles to the site)

    https://nc-news-acw.onrender.com/api/articles
  16. POST /api/topics (allows the user to add topics to the site)

    https://nc-news-acw.onrender.com/api/topics
  17. PATCH /api/articles/:article_id (updates the given article & returns it)

    https://nc-news-acw.onrender.com/api/articles/3
  18. DELETE /api/articles/:article_id (delete the associated article)

    https://nc-news-acw.onrender.com/api/articles/3
  19. DELETE /api/comments/:comment_id (deletes the associated comment)

    https://nc-news-acw.onrender.com/api/comments/3

Developer Setup

  1. Clone the repository by copying the latest https link & typing the below command:

    git clone https://github.com/AliCW/AliCW-be-NC-news.git
  2. Please create .env.development (& if required .env.test) files in the root of the repo so as to connect to the database. The file should contain the below information:

    .env.development

    PGDATABASE=nc_news

    .env.test

    PGDATABASE=nc_news_test
  3. The api was written using node.js version 19.0.0 & psql version 14.5. Installing these distributions or later (if available) is advised

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
    nvm install 19
    apt install postgresql
  4. Install the npm package dependencies by running the below command in the root of the repo:

    npm install
  5. You will need to populate the psql database with information by typing the below command in the root of the repo:

    npm run seed

Testing

  1. To run testing functionality, you can run the below command in the repo root to run all the tests in tests/

    npm run test
  2. If you want to run a specific test file, navigate into tests/ and specify the file in question, e.g:

    cd __tests__/ && npm test api-endpoints.test.js

ElephantSQL discontinuation

Following the shutdown of https://www.elephantsql.com/ - postgresql data is hosted on https://supabase.com/

alicw-be-nc-news's People

Contributors

alicw avatar anthonymedina avatar nc-paul-rogerson avatar p-copley avatar daviidbartlett avatar dav3rid avatar anatdean avatar alexander-cox avatar sssam-c avatar tomosim avatar bainesface avatar isabelmaccabee avatar douglashellowell avatar dentednerd avatar itskatherine avatar liam310 avatar rogersop avatar antariess avatar jimstev2447 avatar nicola-20 avatar two-triangles avatar

Watchers

 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.