feat: add status inspection to api

pull/75/head
Amio 2018-08-05 10:14:34 +08:00
rodzic fdb7ab493b
commit cd16d75168
2 zmienionych plików z 14 dodań i 0 usunięć

Wyświetl plik

@ -4,6 +4,7 @@ const { send } = require('micro')
const { router, get } = require('micro-fork')
const liveFunctions = require('./live-fns/_index.js')
const liveFetcher = require('./live-fetcher.js')
const serveStatus = require('./serve-status.js')
const CACHE_CONTROL = `public, max-age=60, stale-while-revalidate=86400, stale-if-error=86400`
const sMaxAges = {
@ -22,5 +23,6 @@ const serveIndex = (req, res) => send(res, 200, indexContent)
module.exports = router()(
get('/', serveIndex),
get('/_status', serveStatus),
...apiHandlers
)

Wyświetl plik

@ -0,0 +1,12 @@
const axios = require('axios')
const { send } = require('micro')
module.exports = async function (req, res) {
const [
githubRateLimit
] = await Promise.all([
axios('https://api.github.com/rate_limit').then(res => res.data.resources)
])
send(res, 200, { githubRateLimit })
}