Browse Source

docs: add index-api.md

api-cache
Amio 6 years ago
parent
commit
6f28da2918
  1. 6
      libs/index-api.md
  2. 6
      libs/serve-api.js

6
libs/index-api.md

@ -0,0 +1,6 @@
# api.badgen.net
## Examples
- https://api.badgen.net/npm/v/micro
- https://api.badgen.net/npm/dependents/got

6
libs/serve-api.js

@ -1,3 +1,5 @@
const fs = require('fs')
const path = require('path')
const { send } = require('micro') const { send } = require('micro')
const { router, get } = require('micro-fork') const { router, get } = require('micro-fork')
const liveFunctions = require('./live-fns/_index.js') const liveFunctions = require('./live-fns/_index.js')
@ -15,6 +17,10 @@ const apiHandlers = Object.entries(liveFunctions).map(([name, fn]) => {
}) })
}) })
const indexContent = fs.readFileSync(path.join(__dirname, 'index-api.md'), 'utf8')
const serveIndex = (req, res) => send(res, 200, indexContent)
module.exports = router()( module.exports = router()(
get('/', serveIndex),
...apiHandlers ...apiHandlers
) )

Loading…
Cancel
Save