View the API at: https://lc-nc-news.herokuapp.com/api
This project is a demonstration of a RESTful API written in JavaScript and using Express JS alongside PostgreSQL as a database.
A user is able to interact with news data with the following methods:
- GET a list of all of the available endpoints
- GET a list of topics
- GET a list of users
- GET a specific user
- GET a list of articles with the ability to filter by topic, sort by various valid fields, decide upon the sort order and customise the pagination limits and view specific pages
- GET a specific article, including comments
- PATCH a specific article in order to vote on it
- PATCH a specific comment in order to vote on it
- POST a new comment to a specific article
- POST a new article
- DELETE a specific comment
To run a local copy of this API you will require: Node.js (v17.5.0) npm (8.4.1) PostgreSQL (12.9)
Any versions of the above tools that pre-date those listed have not been tested and may not work.
Clone this repository via git clone https://github.com/LiamCurran95/nc-news-BE
Install dependencies via "npm install"
To create / connect with the databases locally there are two required environment files - create these at the root of the repository:
.env.development - PGDATABASE=nc_news .env.test - PGDATABASE=nc_news_test
These files are already referenced in the .gitignore.
Run the two following commands: "npm run setup-dbs" "npm run seed"
This API has been tested with Jest, to initialise the tests run the following command:
npm test
To run a local version of this app run the following command:
npm run start
This will open up a local port (9090, defined in the listen.js file) - requests can be made via apps such as Insomnia.