/be-nc-news

๐Ÿ“ฐ A news API using Express, PostgreSQL and JS [Northcoders back-end portfolio project]

Primary LanguageJavaScript

๐Ÿ—ž๏ธ My News API ๐Ÿ—ž๏ธ



newsstand

Image via Flickr under (CC BY-NC-SA 2.0)


Hello! ๐Ÿ‘‹ Welcome to my news API.


๐Ÿ’ญ Description

This API allows users to create, read, update and delete information by interacting with the database. To view all available endpoints, please visit the hosted version using the URL below.


๐Ÿ  Hosted version

https://davidc-nc-news.herokuapp.com/api

Following this URL will produce a JSON file that will list all available endpoints: with available queries, example request bodies, and example responses.

For example ๐Ÿ‘‡:

Imgur


๐Ÿ–ฅ๏ธ Running the API Locally

๐Ÿšง Before beginning setup, please check you have at least these versions of the following:

  • Node.js - v. 17.5.0
  • Postgres - v. 14.1

After doing so, perform each step, in order:

๐Ÿ’ป โžก๏ธ ๐Ÿ’ป Cloning the repository:

git clone https://github.com/davidptclark/be-nc-news.git

๐Ÿ—๏ธ Install required packages:

Simply run npm install to install the necessary dependencies required.

๐ŸŒ Environment setup:

This repository does not contain the necessary .env files that set the value of PGDATABASE to a specific database, as they are part of the gitignore and will only be stored locally. After cloning, you will need to create two .env files in the root directory:

.env.development

.env.development

.env.test

.env.test

๐ŸŒฑ Seeding local databases:

To start the API, run the command npm start. This will instruct the API to listen on the default port: 9090.

If you would like to reinitialise the database, use the command npm run setup-dbs followed by npm run seed to re-seed the database.

๐Ÿงช Running tests:

The available endpoint have been created using Jest and pre-written tests are found in ./__tests__/. The test files are configured to re-seed the database after each test is complete; to run these tests, as well as any you have written, use the command npm test FILENAME.