Skip to content

Instantly share code, notes, and snippets.

@nathanclevenger
Last active November 30, 2022 11:46
Show Gist options
  • Save nathanclevenger/b90122a628424ad543e6e5049f6eeedf to your computer and use it in GitHub Desktop.
Save nathanclevenger/b90122a628424ad543e6e5049f6eeedf to your computer and use it in GitHub Desktop.
Generate APIs.do Markdown
export default {
fetch: async req => {
// Fetch YAML of Categories, transform to JSON
const apis = await fetch('https://yaml.do/raw.githubusercontent.com/drivly/apis.do/main/apis.yaml').then(res => res.json())
let md = `
# APIs.do: Hypermedia-driven APIs & SDK
`
// ### Core:
// - [APIs.do: Hypermedia-driven APIs](https://apis.do) ([API](https://apis.do/api), [Docs](https://apis.do/docs), [Repo](https://github.com/drivly/apis.do), [Roadmap](https://github.com/drivly/apis.do/issues/1), [Issues](https://github.com/drivly/apis.do/issues))
for (const category in apis) {
md += `### ${category}:\n`
for (const api in apis[category]) {
const host = api.toLowerCase()
md += ` - [${api}: ${apis[category][api]}](https://${host}) ([API](https://${host}/api), [Docs](https://${host}/docs), [Repo](https://github.com/drivly/${host}), [Roadmap](https://github.com/drivly/${host}/issues/1), [Issues](https://github.com/drivly/${host}/issues)) \n`
}
md += `\n`
}
// Loop through categories and APIs and generate markdown
// ### Core:
// - [APIs.do: Hypermedia-driven APIs](https://apis.do) ([API](https://apis.do/api), [Docs](https://apis.do/docs), [Repo](https://github.com/drivly/apis.do), [Roadmap](https://github.com/drivly/apis.do/issues/1), [Issues](https://github.com/drivly/apis.do/issues))
return new Response(md)
}
}
@nathanclevenger
Copy link
Author

nathanclevenger commented Oct 28, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment