Live Link : https://nc-news-project-nc.herokuapp.com/api/
This API mimics the build of a real world backend service that contains different articles, topics, comments and users. It provides full CRUD functionality and was built using TDD with Jest as the testing framework.
The main backend framework used for the routes is Express and for the database PSQL which was installed using the PG npm package.
Below i will provide a brief overview of all the routes available and what they do. ( The endpoints are also available to see in JSON format in the file of this directory "endpoints.json" or you can view them live here : View endpoints )
GET routes
- /api/users ----> Returns an array of objects of all the users available
- /api/users/:username ----> Returns an object with the details of the user found
- /api/topics ----> Returns an array of objects of all the topics available
- /api ----> Returns an object with keys representing all the routes available for usage as well as examples of responses
- /api/articles ----> Returns an array of objects of all the articles available (queries available for this endpoint : author, topic, sort_by, order)
- /api/articles/:article_id ----> Returns an object with the article found
- /api/articles/:article_id/comments ----> Returns an array of objects of all the comments associated to the article specified
POST routes
- /api/topics ----> Returns the created topic. Fields required >>slug: String, description: String || Coming soon
- /api/articles ----> Returns the created article. Fields required >> author: String -> Needs to be the username from the users table, title: String, body: String, (topic: String -> Needs to be the slug from the topics table)
- /api/articles/:article_id/comments ----> Returns the created comment on the article given. Fields required >> username: String -> Needs to be the username from the users table, body: String
PATCH routes
- /api/articles/:article_id ----> Returns the updated article. Fields required >> inc_votes : Number (It will increment the votes, but if you pass a negative number it will subtract)
- /api/comments/:comment_id ----> Returns the updated comment. Fields required >> inc_votes : Number (It will increment the votes, but if you pass a negative number it will subtract)
DELETE routes
- /api/comments/:comment_id ----> Returns status code 204
- /api/articles/:article_id ----> Returns status code 204 || Coming soon
You can also see all the additional packages used for the API beneath
To run this app in your local machine please follow the next steps
-
In your terminal paste this command >>
git clone https://github.com/AngelosGR21/BC-News-Project-Northcoders-.git
to clone the repository in your system. -
Make sure you run
npm install
to install all dependencies needed. -
After all dependencies have been installed run the command
npm run setup-dbs
to create the databases. -
Next to seed the databases run :
npm run seed
for the development datanpm run seedTestData
for the test data
-
Before you run the tests you need to create a .env file in the root of your project
-
After you created the .env file you need to update it with the variables from .env-example
- You're all set, all that's left is to run the tests!
npm test
- Node : 17.6.0
- PSQL : 12.10