This project provides access to Northcoders news, articles, users and comments.
Link below displays all of the available API Endpoints
- Link to NC-News API - https://nc-news-leon-be.herokuapp.com
This application was built with JavaScript and uses:
- Node.js - JavaScript run-time environment
- Express - Web framework
- mongoose - MongoDB object modelling
- EJS - Javascript templating language
- faker.js - Generate data for seed files
- Lodash - JavaScript utility library
- Mocha - JavaScript test framework
- Chai - Node assertion library
- SuperTest - HTTP assertion library
- Nodemon - Monitors for changes and automatially restarts server
You will need to have Node installed before installing other dependencies. Information on how to do this can be found at the Node website.
- Download a copy of the project through GitHub:
git clone https://github.com/leon-northcoders/NC-News-BE.git
- Download the necessary dependencies:
npm i
Before proceeding, you will need to create a config
directory within the root of the project. It is recommended to use a different file for test, production and development node environments, with each exporting the URL location of your MongoDB database.
- Create config file for each node environment, exporting the corresponding URL
exports.DB_URL = 'mongodb://localhost:27017/northcoders_news_test'
- Create
index.js
which exports necessary config file depending on node environment
process.env.NODE_ENV = process.env.NODE_ENV || 'dev'
module.exports = require(`./${process.env.NODE_ENV}`)
The test suite is built with the Mocha test framework, including Chai and Supertest.
There are 31 written tests in the spec folder. To execute the test suite:
npm t
- To run server locally:
npm run dev
- To access your app within a browser or Postman, visit:
http://localhost:9090/
- From there you can browse a list of all of the available API endpoints.
- To seed the development database:
npm run seed:dev
- To seed the production database on Mlab:
npm run seed:prod