Two websites with different styles:
Query from your own database
Reference:
Recommended framework and package manager:
Reference
You may choose your favorite, but the final demo should be compatible with Chrome,Firefox
Reference
It’s much better if you can publish your work as a docker image。
Reference:
FaaS (Function as a Service) is taking on the trend recently. If you are interested, you may try AWS Lambda or knative.
Here’s an example serverless function deployed on Tecent Cloud with Nodejs8.9 triggered by API Gateway:
const request = require('request')
async function getDxyData() {
try {
const body = await new Promise(
(resolve, reject) => {
request({
method: 'GET',
uri: 'https://ncov.dxy.cn/ncovh5/view/pneumonia'
}, (error, response, body) => {
if (error) return reject(error)
resolve(body)
})
}
)
const statistics = JSON.parse(/getStatisticsService\s*=\s*(.*?)}catch/.exec(body)[1])
const timeline = JSON.parse(/getTimelineService\S*\s*=\s*(.*?)}catch/.exec(body)[1])
const areaStatistics = JSON.parse(/getAreaStat\s*=\s*(.*?)}catch/.exec(body)[1])
let listByArea = areaStatistics.map((x) => {
return {
provinceName: x.provinceName,
provinceShortName: x.provinceShortName,
tags: x.tags,
confirmed: x.confirmedCount,
suspected: x.suspectedCount,
cured: x.curedCount,
dead: x.deadCount,
comment: x.comment,
cities: x.cities.map((x) => {
return {
cityName: x.cityName,
confirmed: x.confirmedCount,
suspected: x.suspectedCount,
cured: x.curedCount,
dead: x.deadCount
}
})
}
})
let listByOther = JSON.parse(/getListByCountryTypeService\S*\s=\s*(.*?)}catch/.exec(body)[1])
listByOther = listByOther.map((x) => {
return {
provinceId: x.provinceId,
provinceName: x.provinceName,
provinceShortName: x.provinceShortName,
tags: x.tags,
confirmed: x.confirmedCount,
suspected: x.suspectedCount,
cured: x.curedCount,
dead: x.deadCount,
comment: x.comment,
createTime: x.createTime,
modifyTime: x.modifyTime,
}
})
return {
readme: {
source: 'https://ncov.dxy.cn/ncovh5/view/pneumonia',
statistics: 'Summary',
listByArea: 'Domestic',
listByOther: 'Overseas',
timeline: 'News'
},
statistics,
listByArea,
listByOther,
timeline
}
} catch (err) {
console.log(err)
return null
}
}
exports.main_handler = async (event, context, callback) => {
const data = await getDxyData()
if (!data) return { error: 1, message: 'Load Failed' }
return { error: 0, message: '', data }
}
API Address:
https://service-j6saayzy-1252843818.gz.apigw.tencentcs.com/release/covid19
Reference
Use git to manage your project.