kopia lustrzana https://github.com/badgen/badgen.net
Cleanup legacy files 🏂
rodzic
b4eea98f21
commit
1135a2bec3
|
@ -44,10 +44,6 @@ export function badgenServe (handlers: BadgenServeHandlers): Function {
|
|||
color: 'grey'
|
||||
}
|
||||
|
||||
// if (req.hostname === 'api.badgen.net') {
|
||||
// return serveApi(req, res, { params })
|
||||
// }
|
||||
|
||||
if (req.headers.host.startsWith('flat.') && query.style !== undefined) {
|
||||
query.style = 'flat'
|
||||
}
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
import { send } from 'micro'
|
||||
|
||||
const STALE_CONTROL = 'stale-while-revalidate=604800, stale-if-error=604800'
|
||||
const CACHE_CONTROL = `public, max-age=20, s-maxage=120, ${STALE_CONTROL}`
|
||||
|
||||
export default async function serveApi (req, res, { params }) {
|
||||
res.setHeader('Cache-Control', CACHE_CONTROL)
|
||||
return send(res, 200, params)
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
const got = require('got')
|
||||
const { send } = require('micro')
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
const [githubRateLimit] = await Promise.all([getGithubRateLimit()])
|
||||
const memUsage = process.memoryUsage()
|
||||
const cpuUsage = process.cpuUsage()
|
||||
|
||||
const stats = { githubRateLimit, memUsage, cpuUsage }
|
||||
|
||||
res.setHeader('Content-Type', 'application/json; charset=utf-8')
|
||||
res.setHeader('Cache-Control', 'public, max-age=1, s-maxage=1')
|
||||
send(res, 200, JSON.stringify(stats, null, 2))
|
||||
}
|
||||
|
||||
const getGithubRateLimit = () => {
|
||||
const url = 'https://api.github.com/rate_limit'
|
||||
const token = process.env.GH_TOKEN
|
||||
const headers = token && { Authorization: `token ${token}` }
|
||||
return got(url, { json: true, headers }).then(res => res.body.resources)
|
||||
}
|
Ładowanie…
Reference in New Issue