This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Ultra lightweight Github REST Client */ | |
// original inspiration via https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb | |
const token = 'github-token-here' | |
const githubClient = generateAPI('https://api.github.com', { | |
headers: { | |
'User-Agent': 'xyz', | |
'Authorization': `bearer ${token}` | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { Jsonify } from "type-fest"; | |
// Define new storage types here and below and the storage below will automatically use them. | |
// prettier-ignore | |
type TypedDurableObjectStorageValue<Key extends string> = Jsonify< | |
| Key extends "simple" ? boolean : never | |
| Key extends "complex" ? { age: number } | { name: string } : never | |
| Key extends `template:type:known` ? number : never | |
| Key extends `template:type:${string}` ? string | number : never | |
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addEventListener('fetch', event => { | |
event.respondWith(handleRequest(event.request)) | |
}) | |
const encoder = new TextEncoder(); | |
const decoder = new TextDecoder(); | |
const SECRET_KEY_DATA = encoder.encode('YOUR SECRET KEY'); | |
function normalizeBase64(base64urlencoded) { | |
return base64urlencoded.replace(/-/g, '+').replace(/_/g, '/'); |