Public | Automated Build

Last pushed: 2 months ago
Short Description
API for events, births and deaths that occurred during a specific day of history (Wikipedia).
Full Description

On This Day





About

Application built with Express and React that returns events, births and deaths that occurred during a specific day of history. This information has been retrieved from Wikipedia using a scraper.

API Usage

Episodes

Returns an array of JSON historical episodes, filtered by day, month and type.

  • URL: api/episodes?type=<type>&day=<day>&month=<month>

  • Method: GET

  • URL Query Params:

Parameter Required Possible Values Default Value
type no "all", "events", "births" or "deaths" "all"
day yes Any integer between 1 and 31. -
month yes Any integer between 1 and 12. -
short no true, false false
  • Example Success Response:
    • Code: 200
    • Example Content:
{
  "_id": "593c57b8fe84bd1ded1e9113",
  "day": 17,
  "month": 6,
  "description": "June 17 is the 168th day of the year (169th in leap years) in the Gregorian calendar. There are 197 days remaining until the end of the year. This date is slightly more likely to fall on a Wednesday, Friday or Sunday (58 in 400 years each) than on Monday or Tuesday (57), and slightly less likely to occur on a Thursday or Saturday (56).",
  "__v": 0,
  "deaths": [
    {
      "year": "656",
      "data": "Uthman, Persian ruler (b. 577)",
      "_id": "593c57b8fe84bd1ded1e9216",
      "kw": [
        {
          "title": "656",
          "href": "/wiki/656",
          "_id": "593c57b8fe84bd1ded1e9218"
        },
        {
          "title": "Uthman",
          "href": "/wiki/Uthman",
          "_id": "593c57b8fe84bd1ded1e9217"
        }
      ]
    },
    {
      "year": "676",
      "data": "Pope Adeodatus II",
      "_id": "593c57b8fe84bd1ded1e9213",
      "kw": [
        {
          "title": "676",
          "href": "/wiki/676",
          "_id": "593c57b8fe84bd1ded1e9215"
        },
        {
          "title": "Pope Adeodatus II",
          "href": "/wiki/Pope_Adeodatus_II",
          "_id": "593c57b8fe84bd1ded1e9214"
        }
      ]
    },
    {
      "year": "850",
      "data": "Tachibana no Kachiko, Japanese wife of Emperor Saga (b. 786)",
      "_id": "593c57b8fe84bd1ded1e920f",
      "kw": [
        {
          "title": "850",
          "href": "/wiki/850",
          "_id": "593c57b8fe84bd1ded1e9212"
        },
        {
          "title": "Tachibana no Kachiko",
          "href": "/wiki/Tachibana_no_Kachiko",
          "_id": "593c57b8fe84bd1ded1e9211"
        },
        {
          "title": "Emperor Saga",
          "href": "/wiki/Emperor_Saga",
          "_id": "593c57b8fe84bd1ded1e9210"
        }
      ]
    }, {
      ...
    }
  ]
}

Note: The keywords' link (href) is relative to Wikipedia's domain. For example /wiki/Emperor_Saga turns to be https://wikipedia.org/wiki/Emperor_Saga.

  • Sample Call:
    $.ajax({
      url: "api/episodes?type=deaths&day=17&month=6",
      dataType: "json",
      type : "GET",
      success : function(response) {
        console.log(response);
      }
    });
    

About Short Mode

If the short query string is supplied, no keywords (kw) will be returned in the response.

Setup

Development

  1. Clone and cd into this repository
  2. run npm install (or yarn install)
  3. Export the environment variables DB_HOST and DB_PORT (27017 by default), or alternatively MONGODB_URI.
  4. Turn on your local mongodb server if that is the case.
  5. run nodemon server (turns on the backend server)
  6. run npm run startDev (turns on the frontend development server)

Docker

# Pull and run the application and mongodb
$ docker run -d --name=mongo_db mongo:3.0.15
$ docker run -d --name=onthisday -p 80:9000 --link=mongo_db:mongo_db sasalatart/on-this-day

# Setup the database
$ docker exec onthisday npm run seed

The server's machine should now be redirecting its port 80 to the container's port 9000.

Docker Pull Command
Owner
sasalatart
Source Repository

Comments (0)