Skip to content

Latest commit

History

History
70 lines (54 loc) · 1.42 KB

File metadata and controls

70 lines (54 loc) · 1.42 KB

API

This repository auto-generates the /db folder after each commit to main. The folder includes two files:

categories.json - A list of all categories

resources.json - A list of all APIs

You can then use Octokit to fetch the data from the db folder.

Here's a minimal snippet on how to accomplish that:

import{Octokit}from'octokit'asyncfunctionfetchResources(file: string){constoctokit=newOctokit({auth: process.env.GITHUB_ACCESS_TOKEN})const{ data }=awaitoctokit.rest.repos.getContent({owner: 'marcelscruz',repo: 'dev-resources',path: `/db/${file}.json`,})if(data.download_url){constresult=awaitfetch(data.download_url)if(!result.ok){thrownewError(`Unexpected response ${result.statusText}`)}returnawaitresult.json()}else{thrownewError('Download URL not found')}}

The response will be an object with the following structure:

categories.json:

{"count": number,"data": [{"name": string,"slug": string}]}

resources.json:

{"count": number,"data": [{"name": string,"categories": [string],"description": string,"url": string,"keywords": [string]// Optional}]}