This project serves data from a MongoDB database containing fake news articles, topics, users and article comments. It was built using MongoDB, Node, Express and Mongoose.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
This project uses MongoDB for its database. The database is seeded using mLab, and hosted on Heroku at https://jc-northcoders-news.herokuapp.com/api.
You will need to have MongoDB installed, and ensure that it is running in the background. You can find instructions on how to install MongoDB via the following documentation: https://www.mongodb.com/download-center?jmp=nav
Once installed, you can run it in the background using the following terminal command:
mongod
Fork this project on GitHub by clicking "Fork" in the top right of this GitHub page. This will fork it to your GitHub profile, creating a copy of the repository.
Clone the project from GitHub by clicking the green "Clone or download" button and copying the provided URL.
Navigate on your local machine's command line to the directory you want to clone the project into, and type:
git clone
followed by the copied URL.
Next, open the project in a text editor.
Within the project, the following npm packages are required:
- nodemon
- express
- mongoose
- chai
- chai asserttype
- mocha
- supertest
These can be installed by opening an integrated terminal and typing:
npm i
You will also need to create a config.js file in the root directory, by typing the following into the integrated terminal:
touch config.js
Open config.js and copy the following into it:
process.env.NODE_ENV = process.env.NODE_ENV || 'dev';
const config = {
test: 'mongodb://localhost:27017/nc-news-test',
dev: 'mongodb://localhost:27017/nc-news'
}
module.exports = config[process.env.NODE_ENV];
Once these steps are complete, you can open the project in a developer environment using the terminal command:
npm run dev
If you would like to seed the database prior to running the project in developer mode, replace the above with the command:
npm run seed:dev
To run the automated tests for this system, type:
npm test
into the command line.
To view the tests, view the index.spec.js file inside the project's spec directory.
The tests test each endpoint, in addition to some common errors. See https://jc-northcoders-news.herokuapp.com/api for a list of the project's endpoints.
The test file reseeds the database after each test to ensure the test data is accurate.
- Express - web framework
- MongoDB & Mongoose - database
- mLab - database seeding service
- Heroku - hosting service
Joanna Cholewa
Northcoders tutors
Purple Booth provided a README template