/random-quote-api

This is a simple API built with nodejs, expressjs, and mysql.

Primary LanguageJavaScript

Random Quote API

This is a simple API built with nodejs, expressjs, and mysql. I built this for freeCodeCamp's Random Quote Machine project.

Getting Started

  • Installation:

    • Clone this repo

    • run npm install to install all dependencies

    • Install MYSQL and start the server:
      • You need MySQL running in order to use this project.
      • If you're on Linux, install MySQL for your flavor and start the server.
      • If you're on Mac, you can use MAMP.
      • If you're on Windows, you can use XAMPP or WAMP

    • Open the .env-example file and update the necessary database configs (database username, database password, database host, etc)

    • Run npx sequelize db:migrate to run the migrations and create all the database tables (make sure MSQL is running)
    • Run npx sequelize db:seed:all to seed the database with fake data generated with Faker

    • run npm start to run the app


  • Get Requests

    • Get All Quotes
      • localhost:3000/api/quotes will return all quotes, paginated at 10 records per page.
        • to navigate between paginated page results, do localhost:3000/api/quotes?page=2 and so on
    • Get A single Quote
      • localhost:3000/api/quotes/1 will return the quote with an id of 1
    • Get Quotes by Author ID
      • localhost:3000/api/quotes?authorId=3 will return all quotes for the author with an id of 3

    • Get All Authors
      • localhost:3000/api/authors will return all authors paginated at 10 records per page.
        • to navigate between paginated page results, do localhost:3000/api/authors?page=2 and so on
    • Get a Single Author by ID
      • localhost:3000/api/authors/1 will return the author with an id of 1
    • Get Author By Name
      • localhost:3000/api/authors?authorName=<author's name here>
  • Post Requests