Light weight rest api that uses express.js with custom middleware to serve data from file system.
npm install && npm start
npm run debug
/api/lotcodes
/api/breakdown-strategies
/api/breakdown/${breakdown-strategy}/${lotcode}
GET /api/breakdown/region/15MPPN002-VK
{
"breakDownType": "region",
"lotCode": "15mppn002-vk",
"breakdown": [
{
"region": "Mornington",
"percentage": 81
},
{
"region": "Yarra Valley",
"percentage": 10
},
{
"region": "Heathcote",
"percentage": 5
},
{
"region": "Macedon",
"percentage": 2
},
{
"region": "Port Phillip",
"percentage": 2
}
]
}
GET /api/lotcodes
{
"lotCodes": [
"11YVCHAR001",
"11YVCHAR002",
"15MPPN002-VK"
]
}
GET /api/breakdown-strategieies
{
"strategies": [
"year",
"variety",
"region",
"year-variety"
]
}
|-- Project Dir
|-- .babelrc
|-- index.js
|-- package-lock.json
|-- package.json
|-- data
| |-- 11YVCHAR001.json
| |-- 11YVCHAR002.json
| |-- 15MPPN002-VK.json
| |-- index.js
| |-- valid_params.json
|-- src
├───handlers/
│ ├───breakdown.js
│ ├───breakdownStrategies.js
│ ├───index.js
│ └───lotCodes.js
├───lib/
│ ├───breakDown.js
│ ├───dataConnector.js
│ ├───handleErr.js
│ ├───index.js
│ ├───params.js
│ └───resBuilder.js
└───middleware/
├───index.js
├───setBreakDownStrategy.js
└───setLotCode.js