2
3export const artICGetRandom = (limit: number = 1) =>
4 fetchJSON("https://api.artic.edu/api/v1/search", {
5 method: "POST",
6 headers: {
1export const axiosEx = (async () => {
2 const { default: axios } = await import("https://esm.sh/axios");
3 let r = await axios.get("https://api.github.com/users/stevekrouse/following");
4 return JSON.stringify(r);
5})();
1export let openaiOpenAPI = `
2openapi: 3.0.0
3info:
4 title: Val Town API
5 description: |
6 The Val Town API provides services to evaluate JavaScript and TypeScript expressions, run vals as APIs, either as functions or Express handlers.
7
8 Learn more at [https://docs.val.town](https://docs.val.town)
10servers:
11 - url: https://stevekrouse-chatgptplugin.express.val.run
12 description: Val Town API v1
13
14components:
17 type: http
18 scheme: bearer
19 bearerFormat: API Key
20 schemas:
21 JSON:
71 summary: "id"
72 description: |
73 This val is a function that returns its arguments. It is useful for testing how the API handles the arguments passed to it.
74
75 View the val at [https://val.town/v/stevekrouse.id](https://val.town/v/stevekrouse.id)
3export const googleOauthDebug = (async () => {
4 const client = await googleClient();
5 const scopes = ["https://www.googleapis.com/auth/calendar"];
6 const authorizationUrl = client.generateAuthUrl({
7 scope: scopes,
2import { pros } from "https://esm.town/v/stevekrouse/pros";
3import { email } from "https://esm.town/v/std/email?v=9";
4import { verifyAPIAuth } from "https://esm.town/v/stevekrouse/verifyAPIAuth";
5
6export async function r2Proxy(key, value, auth) {
7 let { handle } = await verifyAPIAuth(auth);
8 if (!handle)
9 return "Could not verify auth";
1import { discordAPI } from "https://esm.town/v/stevekrouse/discordAPI";
2
3export let getDiscordGuilds = ({token, tokenType}) => discordAPI({
4 token,
5 tokenType,
2
3// token_type = 'Bot' | 'Bearer'
4export let discordAPI = ({path, tokenType, token}) => fetchJSON(
5 `https://discord.com/api/${path}`,
6
7 // https://discord.com/developers/docs/reference#authentication
2
3export let discordFetch = (token, route) => fetchJSON(
4 `https://discord.com/api/${route}`,
5 {
6 headers: {
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export let testWebhook = fetchJSON("https://api.val.town/eval/@stevekrouse.webhook", {method: "POST"})
2
3export let fetchHeaders2 = Object.fromEntries(
4 (await fetch("https://swapi.dev/api/people/1/")).headers
5);