Skip to content

Commit

Permalink
Update badgen to 2.0.0, support flat style #10
Browse files Browse the repository at this point in the history
  • Loading branch information
amio committed Jul 17, 2018
1 parent 8a6199d commit e2b9bd7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions libs/serve-badge.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const badgen = require('badgen')

function serveBadge (req, res, params) {
params.style = req.headers.host === 'flat.badgen.net' ? 'flat' : undefined

res.writeHead(200, {
'Content-Type': 'image/svg+xml;charset=utf-8',
'Cache-Control': 'public, max-age=360, s-maxage=86400'
Expand Down
3 changes: 2 additions & 1 deletion libs/setup-live-badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const waitings = {} // Cache ongoing fetching, prevent redundant request
module.exports = function (router) {
Object.entries(liveFns).forEach(([name, fn]) => {
router.get(`/${name}/*`, async (req, res, params) => {
const style = req.headers.host === 'flat.badgen.net' ? 'flat' : undefined
const {
subject = name,
status = 'unknown',
Expand All @@ -17,7 +18,7 @@ module.exports = function (router) {
'Content-Type': 'image/svg+xml;charset=utf-8',
'Cache-Control': 'public, max-age=20, s-maxage=' + sharedMaxAge
})
res.end(badgen({subject, status, color}))
res.end(badgen({subject, status, color, style}))
})
})
}
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"axios": "^0.18.0",
"badgen": "^1.1.3",
"badgen": "^2.0.0",
"chrome-webstore": "^1.0.0",
"find-my-way": "^1.15.1",
"lru-cache": "^4.1.3",
Expand Down

0 comments on commit e2b9bd7

Please sign in to comment.