badgen.net/libs/serve-404.ts

22 wiersze
463 B
TypeScript
Czysty Zwykły widok Historia

2019-07-06 00:56:03 +00:00
import url from 'url'
2019-05-14 01:20:26 +00:00
import serveBadge from './serve-badge'
export default function (req, res) {
const params = {
subject: 'Badgen',
status: '404',
color: 'orange'
}
2019-07-06 00:56:03 +00:00
const { query } = url.parse(req.url, true)
if (query.style === undefined) {
const host = req.headers['x-forwarded-host'] || req.headers.host
if (host.startsWith('flat')) {
query.style = 'flat'
}
}
serveBadge(req, res, { code: 404, params, query })
2019-05-14 01:20:26 +00:00
}