Back to APIs list

Github API examples & templates

Use these vals as a playground to view and fork Github API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
tmcw avatar
octokitGraphQLExample
@tmcw
Script
octokit/graphql This alternative driver for the GitHub API exposes it via GraphQL.
tzq avatar
monitoringZSearch
@tzq
Script
An interactive, runnable TypeScript val by tzq
pomdtr avatar
blog
@pomdtr
HTTP (deprecated)
Val Town Blog A blog written, developed and hosted on val.town. How ? Each article on this blog is contained single val, with a #blog tag. See this example article . // #blog // title: Example Post import { article } from "https://esm.town/v/pomdtr/article"; import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo"; import { html } from "https://esm.town/v/stevekrouse/html?v=5"; export async function examplePost(req: Request) { const { author, name } = extractValInfo(import.meta.url); return html(await article(author, name)); } Each of these post work on it's own . This val is able to: list them with the /v1/search api (with a #blog query) post with different author than the owner of this val will be filtered out only public vals will be listed render the readme of those vals using remark (with github styling) This process run each time a user visit the web endpoint , so the blog is always up to date. You can get your own instance of the blog by just forking this val .
karfau avatar
SignatureCheck
@karfau
Script
This val has been created to avoid certain shortcomings of @vtdocs.verifyGithubWebhookSignature . So it was created as a mix/evolution of two sources: The github docs about securing webhook Some code from the @octokit/webhhokmethods package This code is covered by tests which you can copy to run them, see @karfau.test_SignatureCheck This val does not contain any val.town specific code ( @ -imports, console.email ...), so it should be possible to run in Deno as is, potentially even in modern browsers (that support crypto and TextEncoder and modern ES syntax). Usage const myGithubWebhook = (req: Request) => { const {verify} = @karfau.SignatureCheck(); // you have to call it to get the verify function! const body = await req.text(); const signature = req.headers.get("X-Hub-Signature-256"); const verified = await verify( {payload:body, signature}, @me.secrets.myGithubWebhookSecret, // optionally provide fallback secrets (as many as needed) // @me.secrets.myGithubWebhookSecretFallback ); if (!verified) { return new Response(`Not verified`, 401); } const payload = JSON.parse(body); // actually do things in your webhook }; By default the reason for failing verification is logged to console.error , but you can pass it a different handler: const {verify} = @karfau.SignatureCheck((reason) => { throw new Error(reason); }); (be aware that it will silently fail if you don't try catch it in an endpoint and the return code will be 502) Why @vtdocs.verifyGithubWebhookSignature has the following issues: it relies on the verify method of the outdated @octokit/webhooks-methods@3.0.2 which has (at least) two bugs that can make a difference when used in a webhook it can throws errors instead of just returning false , which can be triggered by sending an invalid signature it can be lured into checking a SHA1 signature if the signature header starts with sha1= you need to pass the secret and payload as argument to the val, which makes them appear in the evaluation logs you produce ( they are only visible for the author of the val if you run them as an API , but it still feels odd to see the secret in the evaluation logs.) parameters are all of type string and the order can be confused you can not use fallback secrets for rotating
willthereader avatar
honoExample
@willthereader
HTTP (deprecated)
Forked from maxm/honoExample
pomdtr avatar
codeOnValTown
@pomdtr
Script
Forked from andreterron/codeOnValTown
vlad avatar
blocks
@vlad
HTTP (deprecated)
Forked from vlad/blocks_inner
Davidkim avatar
EmailNotifIfDidntCode
@Davidkim
Cron
An interactive, runnable TypeScript val by Davidkim
sourishkrout avatar
getRunmeTotals
@sourishkrout
Script
An interactive, runnable TypeScript val by sourishkrout
pomdtr avatar
invoiceTemplate
@pomdtr
HTTP (deprecated)
Forked from pomdtr/oranda
willthereader avatar
Jumpchain_Website
@willthereader
HTTP
Forked from willthereader/homepage
rodrigotello avatar
valTownInspoList
@rodrigotello
Script
Val Town inspiration & use cases list List [as object] used in Val Town's use cases and inspiration. Check it out at in /examples/use-cases and /docs/tutorial/4
willthereader avatar
codeOnValTown
@willthereader
Script
Forked from andreterron/codeOnValTown
platoff avatar
salmonMonkey
@platoff
HTTP (deprecated)
Forked from ianvph/posthogGitHubStarCapture
stevekrouse avatar
purpleOctopus
@stevekrouse
HTTP (deprecated)
Forked from stevekrouse/dateme
willthereader avatar
coralPuma
@willthereader
Script
Forked from andreterron/codeOnValTown