Git Product home page Git Product logo

ncnews's Introduction

NorthCoders NC News API

A RESTful API built to serve data to a reddit style website DC News. The API is built using Express.js, Node.js, Knex.js and PostgreSQL.

Getting Started

Please follow the steps below to run the API on your machine.

Prerequisites

Check if you already have node.js by typing the following command in your terminal:

node –v

If node is not already installed, please follow instructions at Node.js (npm will be installed with Node).

Check if git is installed on your machine by typing the following command in your terminal:

git –version

If git is not installed, please follow instructions at git

You will also need PostgreSQL

Installing

To run this API you will need to clone it to your local machine and install all it dependencies.

Clone this GitHub repository into the folder you want to install it

git clone https://github.com/DAVIDCORNEY/ncnews.git

Make a file knexfile.js in the root of the NC News folder (at the same level as the app.js and listen.js files) and copy the following code into it. This file name has been added to the .gitignore file.

const ENV = process.env.NODE_ENV || "development";
const { DB_URL } = process.env;

const baseConfig = {
  client: "pg",
  migrations: {
    directory: "./db/migrations"
  },
  seeds: {
    directory: "./db/seeds"
  }
};

const customConfigs = {
  production: {
    connection: `${DB_URL}?ssl=true`
  },
  development: {
    connection: {
      database: "ncnews"
    }
  },
test: {
    connection: {
      database: "ncnews_test"
    }
  }
};

module.exports = { ...baseConfig, ...customConfigs[ENV] };

Install all the dependencies

npm install

Start your database PostgreSQL

In the terminal run the following commands

Set up the database

npm run setup-dbs

Seed the development database

npm run seed

Run the server locally

npm run dev

The API can be accessed at localhost:9090

API Endpoints

All the available endpoints on the API can be found by clicking here

Running the tests

All tests are available in the app.spec.js file inside the spec folder.

Testing was carried out with Mocha, Chai, Chai-sorted and Supertest

To run tests, type the following in the terminal

npm test

Deployment

The app has been deployed with Heroku

Built With

Authors

David Corney

Acknowledgments

Thank you to all the tutors at Northcoders Manchester.

ncnews's People

Contributors

maseh87 avatar davidcorney avatar milanshen 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.