Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

London10_Afsha_Hossain_Node_Week1_quote-server #324

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Commits on Jul 17, 2023

  1. Level 1 Challenge - make the quote server

    Added a /quotes route using Glitch and VS code:
    
    https://afsha1-quote-server.glitch.me/quotes
    localhost:3000/quotes
    
    Add a /quotes/random route using Glitch and VS code:
    
    https://afsha1-quote-server.glitch.me/quotes/random
    localhost:3000/quotes/random
    Afsha10 committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    d601292 View commit details
    Browse the repository at this point in the history
  2. Level 2 Challenge - allow quote searches!

    In this level of the challenge I have allowed the user of my quotes API to search my list of quotes.
    
    Added a /quotes/search?term route using Glitch and VS code:
    
    https://afsha1-quote-server.glitch.me/quotes/search?term=life https://afsha1-quote-server.glitch.me/quotes/search?term=success https://afsha1-quote-server.glitch.me/quotes/search?term=miss
    
    localhost:3000/quotes/search?term=life
    localhost:3000/quotes/search?term=success
    localhost:3000/quotes/search?term=miss
    Afsha10 committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    ad6c32e View commit details
    Browse the repository at this point in the history
  3. An intermediate step - echo the parameter

    Making a simple test route that takes a query parameter and repeats the word back to the user.
    
    Tested:
    
    https://afsha1-quote-server.glitch.me/echo?word=ismail
    localhost:3000/echo?word=ismail
    Afsha10 committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    f449d27 View commit details
    Browse the repository at this point in the history

Commits on Jul 18, 2023

  1. Challenge (Intermediate): Use a library to make random picking easier

    Used a library called lodash to make it simpler to do tasks like picking randomly from an array.
    
    Tested:
    https://afsha1-quote-server.glitch.me/quotes/random
    localhost:3000/quotes/random
    
    To install the lodash library:
    
    - edited the file package.json...
    - added a line for lodash in the dependencies (we'll already see one for "express").
    - We can use "*" as the version number for now.
    - If we're running locally, we will need to run npm install to set up the dependency. If we're using Glitch, it will automatically install it.
    - Added a "require" line in your server.js so that we can use the library.
    - const lodash = require('lodash');
    
    then we can use use code inside the pickFromArray function
    
    lodash.sample(myArray)
    Afsha10 committed Jul 18, 2023
    Configuration menu
    Copy the full SHA
    3779568 View commit details
    Browse the repository at this point in the history
  2. Challenge (Advanced): Add a React app as a front-end

    - Made a very simple React app and named it quotes-react-app
    - Had it fetch a random quote from your server on glitch. We had to enable CORS on the express app. See below.
    
    We installed and enabled CORS in order to allow our JSON to be loaded from a different server (glitch.me) than our React app was initially loaded (probably netlify.com).
    
    in package.json added a dependency for "cors": "^2.8.5"
    
    Then in our server.js added...
    
    var cors = require('cors')
    
    and
    
    app.use(cors())
    
    Then we host our react app on netlify
    Afsha10 committed Jul 18, 2023
    Configuration menu
    Copy the full SHA
    0bfcb40 View commit details
    Browse the repository at this point in the history
  3. testing for deployment

    Afsha10 committed Jul 18, 2023
    Configuration menu
    Copy the full SHA
    66be72b View commit details
    Browse the repository at this point in the history
  4. Fix a bug in the search end point

    Made sure the search term in the search end point is also case insensitive by adding .toLowerCase() to searchQuery.
    Afsha10 committed Jul 18, 2023
    Configuration menu
    Copy the full SHA
    ff33c6b View commit details
    Browse the repository at this point in the history

Commits on Jul 20, 2023

  1. Ideas for further work: Use YOUR favourite quotes

    Added my own theory and some of my favourite quotes by Nietzshe.
    Afsha10 committed Jul 20, 2023
    Configuration menu
    Copy the full SHA
    4e027c9 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    68b1a9b View commit details
    Browse the repository at this point in the history

Commits on Aug 25, 2023

  1. Configuration menu
    Copy the full SHA
    9aef9f0 View commit details
    Browse the repository at this point in the history