Skip to content

This project is to create a RESTful API for a news style website using Express, PostgreSQL and Node-postgres.

Notifications You must be signed in to change notification settings

mandeep-s1ngh/be-nc-news

Repository files navigation

Northcoders News API

Summary

This project is part of my portfolio whilst enrolled on the NorthCoders Software Engineering bootcamp. I am creating a RESTful API for a news website.

It uses Express, PostgreSQL, and the interaction with the database was done using node-postgres.


Hosted Version

Firstly, I would recommend installing the JSON viewer chrome extension that will display the JSON data in a nicely formatted way.

You can find the hosted version of the API here - https://nc-news-api-e6xe.onrender.com/

The list of available endpoints can be found here - https://nc-news-api-e6xe.onrender.com/api


Screenshots

Endpoints


Tech Stack

  • Express
  • JavaScript
  • Jest
  • PostgreSQL

Local Setup

  1. To clone the repo, open up your terminal and run git clone https://github.com/mandeep-s1ngh/be-nc-news.git - once you have it cloned, move the folder to your usual directory for projects (if necessary).

  2. You can then open up the folder in your code editor of choice and run npm install to install all the dependencies.

  3. You would need to have PostgreSQL installed which will fire up a PostgreSQL server up once installed and allow you to setup the databases (info can be found further below).


Environment Variables

Once that is done, You will need to define the PGDATABASE environment variable which is used by PSQL to define the name of the databases to be used for the API. There are two databases: one for the test data and one for the dev data. To set up the environment variables, please create the following two files in the root of the project:

  1. .env.test which will need to contain the following line of code: PGDATABASE=nc_news_test.

  2. .env.development which will need to contain the following line of code: PGDATABASE=nc_news


Setup and Seed the local databases

You can then proceed to setup and seed the databases by opening a terminal inside the root of the project then:

1.Setup the databases: npm run setup-dbs

2.Seed the databases: npm run seed


Running the Test Suite

Jest and Supertest are used for the test suite and if you would like to run the tests associated with each endpoint.

You can run the test file by opening a terminal in the root of the project and run npm test app.test.js

You can append .only (which is a Jest global) to a describe block to run the tests associated with a specific endpoint or to an it block to run a specific test.


Interacting with the endpoints

You can run npm start to start the server and use something like Insomnia to interact with the endpoints, send requests and recieve responses.

About

This project is to create a RESTful API for a news style website using Express, PostgreSQL and Node-postgres.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 20