/breads-server

Server code for Breads. Keep track of what you read online, and see what your friends are reading.

Primary LanguageJavaScriptOtherNOASSERTION

Breads API

An Express REST API service, Python web scraper, and MySQL database for breads.io. See breads-client for front end code and more details about the project.

Table of Contents

Installing

After you have forked the project and downloaded the code, install the necessary dependencies using npm or yarn.

To install the packages through npm, run the command npm install

To install the packages through yarn, run the command yarn add

NOTE: In the rest of the documentation, you will come across npm being used for running commands. To use yarn in place of npm for the commands, simply substitute npm for yarn. Example, npm start as yarn start. For more help, checkout migrating from npm.

Running

After installing dependencies and creating a local mySQL database,

1. Import seed data

  • mysql -u [USERNAME] -p [DATABASE] < mysql/tables.sql - create tables
  • mysql -u [USERNAME] -p [DATABASE] < mysql/import.sql - import data

2. Add environment variables

MySQL

  • LOCAL_HOST - local MySQL hostname
  • LOCAL_USER - local MySQL username
  • LOCAL_DBPASSWORD - local MySQL password
  • LOCAL_DB - local MySQL database name

JWT - create a secret key for JWT based authentication

  • SECRET_KEY - JWT secret key

Cloudinary - Used for image hosting. Set up a free account to get a cloud name, API key, and API Secret (only needed if working on user CRUD)

  • CLOUDINARY_CLOUD_NAME - Cloud Name
  • CLOUDINARY_API_KEY - API Key
  • CLOUDINARY_API_SECRET - API Secret

Link Preview - Used as a fallback for the webscraper. Set up a free account to get an API key (only needed if working on webscraper)

  • LINK_PREVIEW_KEY - API Key

Nodemailer - Used to send password reset emails. Add an email login information (only needed if working on reset password feature)

  • EMAIL_LOGIN - email address
  • EMAIL_PASSWORD - email password
  • EMAIL_URL - frontend url (i.e 'http://localhost:3000')

3. Run npm start

Testing

There are currently no tests. (This would be a great way to contribute!)

Deploying

  1. Keep your fork in sync with this repository (how to merge conflicts):
# Add a new remote upstream repository
git remote add upstream https://github.com/zero-to-mastery/breads-server.git

# Sync your fork
git fetch upstream
git checkout master
git merge upstream/master
  1. Push changes to your repo:

git push origin master

  1. In your repo GitHub page, create a pull request to the development branch. This will allow us to see changes in a staging environment before merging to master.

  2. If everything runs correctly, your pull request will be merged into master.

Technologies

Near Future