This exercise requires a working Postgres DB server with the homework database from https://github.com/CodeYourFuture/SQL-Coursework-Week1/tree/main/2-classes-db.
- Initialise a new Node/Express web server.
- Set up a connection pool to the
homeworkdatabase with node-posgtres. - Create a
GET /spendsendpoint that returns the list of all spends as a JSON array of objects. Each object should contain thedate,descriptionandamountproperties. - Create a
GET /suppliersendpoint that returns the list of the names of all suppliers as a JSON array of strings. Make sure the response is an array of strings and not an array of objects! - Extend the
GET /spendsendpont to return a more compete list of spends. Each object should contain theexpense_area,expense_type,supplier,date,descriptionandamountproperties. The objects should not include any IDs, that is, the tables should be joined together.
[
{
"date": "2021-03-31T22:00:00.000Z",
"description": "Medical Equipment - Imaging System",
"amount": "306375"
},
{
"date": "2021-03-31T22:00:00.000Z",
"description": "Annual Fee",
"amount": "319646"
},
{
"date": "2021-03-31T22:00:00.000Z",
"description": "Staff Nurse",
"amount": "351630"
}
][
"INTERCLASS PLC",
"FRESENIUS MEDICAL CARE UK LTD",
"SIEMENS HEALTHCARE LTD",
"JMG ROOFING LTD"
][
{
"expense_area": "Balance Sheet",
"expense_type": "AUC Additions",
"supplier": "E MANTON LTD",
"date": "2021-03-31T22:00:00.000Z",
"description": "Refurbishment of Utilities at the Alexandra Hospital",
"amount": "48270"
},
{
"expense_area": "COO Operational Team",
"expense_type": "External Contractors",
"supplier": "TRANSFORM HOSPITAL GROUP LTD",
"date": "2021-03-31T22:00:00.000Z",
"description": "OMF Services",
"amount": "48750"
},
{
"expense_area": "Balance Sheet",
"expense_type": "AUC Additions",
"supplier": "SPELLER METCALFE MALVERN LTD",
"date": "2021-03-31T22:00:00.000Z",
"description": "Breast Screening unit extension",
"amount": "49205"
}
]