Giter VIP home page Giter VIP logo

nc-news-api's Introduction

Northcoders News API

This is an API for accessing application data programmatically from a database. It mimics a real world backend service (such as Reddit) where the API would provide information to the front end architecture. The database consists of four tables: users, articles, topics, and comments.

A hosted version of the API is available at https://nc-news-api-fa1t.onrender.com. The API is hosted on Render, and the database is hosted on ElephantSQL. A list of enpoints can be obtained at /api.

Note that the API is hosted on the Render free tier and the web services will sleep after 15 minutes of inactivity. If the web service is asleep it will take several seconds to receive a response from an incoming request.

Setup required to run locally

  • Node.js (v21.6.0 or above) and PostgresQL (v14.11 or above).
  • Clone this repository to your local machine using the URL https://github.com/marcusyoung/nc-news-api.git.
  • Run npm -i to install any dependencies.
  • create .env files to hold the test and development database names (see below for further details).
  • Seed the local database by running npm run setup-dbs.

Defining environment variables

Two files: .env.test and .env.development must be created at the top level of the file structure. These should define the environment variable PGDATABASE for the test and development database respectively. Set PGDATABASE to equal the name used for the relevant database in your local setup. The two files should be git ignored.

It is assumed that the password to connect to your PostgreSQL database has been saved to a .pgpass file in your home folder. If not, you may need to define additional environment variables in the .env files.

Running tests

  • Unit and integration test can be run using: npm test
  • To run only integration tests use: npm test app
  • To run only unit tests use: npm test utils

When running the integration tests, the test database will be seeded with the test data prior to each test being run.

nc-news-api's People

Contributors

marcusyoung avatar anthonymedina avatar nc-paul-rogerson avatar p-copley avatar daviidbartlett avatar dav3rid avatar anatdean avatar alexander-cox avatar sssam-c avatar tomosim avatar bainesface avatar callumu21 avatar jimstev2447 avatar isabelmaccabee avatar antariess avatar douglashellowell avatar dentednerd avatar itskatherine avatar liam310 avatar rogersop avatar corkesw avatar elijaharley avatar nicola-20 avatar two-triangles avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.