Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Initially we sign to put everything query parameter in the request body, in order to make the URL string more readable for users, but soon we realize that GET request doesn’t contain request body, therefore we have two options: to put query in query string, or to use POST request for the usage of request body, but to keep request format in standard, we have finally choose the query string as our selection.

Accessing Swagger Documentation

In local machine: http://localhost:4000/api-docs

In deployed public URL: https://news-website-seng3011.herokuapp.com/api-docs

...

API usage

Return all reports that match the parameters given

...

Code Block
languagejson
[
  {
    "url": "http://www.upi.com/Top_News/World-News/2013/05/15/Salmonella-poisoning-outbreak-in-Australia/UPI-30421368619035/ ",
    "headline": "Salmonella poisoning outbreak in Australia",
    "main_text": "DICKSON, Australia, May 15 (UPI) --  At least 100 people have been diagnosed with salmonella poisoning after eating at a new restaurant in Australia, health officials said.",
    "reports": []
  },
  {
    "url": "https://www.foodsafetynews.com/2021/11/salmonella-top-cause-of-foodborne-outbreaks-in-australia/ ",
    "headline": "",
    "main_text": "Salmonella dominated reported outbreaks in Australia in 2016 causing several large incidents, according to a study published recently.",
    "reports": []
  },
  {
    "url": "https://www.foodsafetynews.com/2021/07/salmonella-dominates-outbreaks-in-australia/ ",
    "headline": "",
    "main_text": "More than 450 foodborne outbreaks were reported over a three-year period in Australia, according to a new study.",
    "reports": []
  },
  "1 article(s) could not be scraped from: [{\"url\":\"http://www.healthcanal.com/infections/36035-Deadly-virus-discovered-bats-also-jumps-species.html \"}]"
]

Return User can query a single report that match the databy providing

Code Block
GET/report/?{:reportId}

Accessing Swagger Documentation

In local machine: http://localhost:4000/api-docs

In deployed public URL: https://news-website-seng.herokuapp.com/api-docs

...

...

User (frontend) related Actions

Return all user saved report by userId

...

Each user will be login to our web APP by username and password. After login, user have ability to save/like the report as they wish. The saved report will be written in the database and can be Unsave as they wish. The potential usesage of this will be

...

Return all user saved report by username

Request:

Code Block
languagejs
GET/report/user/:userIdusername/

Save report to corresponding user, return success report saved

Code Block
POST/report/:userId/:reportId

Delete report by userId and report id, return success deleted

...

languagejs

...

Response:

Code Block
[
  {
    "url": "http://www.upi.com/Top_News/World-News/2013/05/15/Salmonella-poisoning-outbreak-in-Australia/UPI-30421368619035/ ",
    "headline": "Salmonella poisoning outbreak in Australia",
    "main_text": "DICKSON, Australia, May 15 (UPI) --  At least 100 people have been diagnosed with salmonella poisoning after eating at a new restaurant in Australia, health officials said.",
    "reports": []
  },
  {
    "url": "https://www.foodsafetynews.com/2021/11/salmonella-top-cause-of-foodborne-outbreaks-in-australia/ ",
    "headline": "",
    "main_text": "Salmonella dominated reported outbreaks in Australia in 2016 causing several large incidents, according to a study published recently.",
    "reports": []
  },
  {
    "url": "https://www.foodsafetynews.com/2021/07/salmonella-dominates-outbreaks-in-australia/ ",
    "headline": "",
    "main_text": "More than 450 foodborne outbreaks were reported over a three-year period in Australia, according to a new study.",
    "reports": []
  },
  "1 article(s) could not be scraped from: [{\"url\":\"http://www.healthcanal.com/infections/36035-Deadly-virus-discovered-bats-also-jumps-species.html \"}]"
]

User can Save report to corresponding usernameand reportId return success saved report.

Request:

Code Block
POST/report/user/:username
Requset Body: {
  Reports:[
    {
      "url": "http://www.upi.com/Top_News/World-News/2013/05/15/Salmonella-poisoning-outbreak-in-Australia/UPI-30421368619035/ ",
      "headline": "Salmonella poisoning outbreak in Australia",
      "main_text": "DICKSON, Australia, May 15 (UPI) --  At least 100 people have been diagnosed with salmonella poisoning after eating at a new restaurant in Australia, health officials said.",
      "reports": []
    },
  ]
}

Response:

Code Block
{
    "url": "http://www.upi.com/Top_News/World-News/2013/05/15/Salmonella-poisoning-outbreak-in-Australia/UPI-30421368619035/ ",
    "headline": "Salmonella poisoning outbreak in Australia",
    "main_text": "DICKSON, Australia, May 15 (UPI) --  At least 100 people have been diagnosed with salmonella poisoning after eating at a new restaurant in Australia, health officials said.",
    "reports": []
  },

User can Unsave/Remove report by usernameand reportId, return success deleted report

Request:

Code Block
languagejs
DELETE/report/user/:username/:reportId

Response:

Code Block
{
    "url": "http://www.upi.com/Top_News/World-News/2013/05/15/Salmonella-poisoning-outbreak-in-Australia/UPI-30421368619035/ ",
    "headline": "Salmonella poisoning outbreak in Australia",
    "main_text": "DICKSON, Australia, May 15 (UPI) --  At least 100 people have been diagnosed with salmonella poisoning after eating at a new restaurant in Australia, health officials said.",
    "reports": []
  },

Sample disease report

Code Block
languagejs
{
   "url": "https://www.who.int/csr/don/17-january-2020-novel-coronavirus-japan-ex-china/en/",
   "date_of_publication": "2020-01-17 xx:xx:xx",
   "headline": "Novel Coronavirus – Japan (ex-China)",
   "main_text": "On 15 January 2020, the Ministry of Health, Labour and Welfare, Japan (MHLW) reported an imported case of laboratory-confirmed 2019-novel coronavirus (2019-nCoV) from Wuhan, Hubei Province, China. The case-patient is male, between the age of 30-39 years, living in Japan. The case-patient travelled to Wuhan, China in late December and developed fever on 3 January 2020 while staying in Wuhan. He did not visit the Huanan Seafood Wholesale Market or any other live animal markets in Wuhan. He has indicated that he was in close contact with a person with pneumonia. On 6 January, he traveled back to Japan and tested negative for influenza when he visited a local clinic on the same day.",
   "reports": [
      {
         "event_date": "2020-01-03 xx:xx:xx to 2020-01-15",
         "locations": [
            {
               "country": "China",
               "location": "Wuhan, Hubei Province"
            },
            {
               "country": "Japan",
               "location": ""
            }
         ],
         "diseases": [
            "2019-nCoV"
         ],
         "syndromes": [
            "Fever of unknown Origin"
         ]
      }
   ]
}

The database design

...

We design a light weight database with 4 fields, the country and city are storing for fast enumerate purpose in query suggestions.

...

  • Postman: API testing application

    • We chose Postman over other tools such as Insomnia to test our API as a few of our members had experience using it

    • Postman also provides the ability to collaborate as a team to write, store and run test cases

Specific Libraries:

Web scraping - Puppeteer

...

:

...

Library - PuppeteerJS, Morgan(logger), Winston(Logger), Nodemon, CORS (TODO)

...