Skip to content

AliCW/AliCW-be-NC-news

Repository files navigation

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/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published