https://github.com/freinet12/random-quote-api
This is a simple API built with nodejs, expressjs, and mysql.
https://github.com/freinet12/random-quote-api
api express mysql nodejs sequelize
Last synced: 6 months ago
JSON representation
This is a simple API built with nodejs, expressjs, and mysql.
- Host: GitHub
- URL: https://github.com/freinet12/random-quote-api
- Owner: freinet12
- Created: 2019-10-16T19:31:01.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T06:45:00.000Z (over 3 years ago)
- Last Synced: 2025-04-02T12:35:27.554Z (over 1 year ago)
- Topics: api, express, mysql, nodejs, sequelize
- Language: JavaScript
- Size: 175 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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=
- Post Requests