7 const [handle, encodedSignedMessage] = matches.slice(1);
8 const publicKey = Buffer.from(
9 await __utils__.api(handle + ".vsPublicKey"),
10 "base64",
11 );
51 Accept: "application/vnd.github+json",
52 Authorization: req.get("Authorization"),
53 "X-GitHub-Api-Version": "2022-11-28",
54 };
55 const path = `https://api.github.com/repos/${shortlink_repo}/contents/public/_redirects`;
56 const getRes = await fetch(path, {
57 method: "GET",
84 headers,
85 body: JSON.stringify({
86 message: `Adding '${shortlink}' shortlink via API`,
87 content: Buffer.from(redirects).toString("base64"),
88 sha,
2Gets information about a specific val.
3
4To access private vals, pass your API token as a secret to the function. Read more about [authentication](https://docs.val.town/api/authentication) to understand how to generate a token and save it as a secret.
5
6Migrated from folder: Archive/getVal
1// https://developer.mozilla.org/en-US/docs/Web/API/btoa
2import { Buffer } from "node:buffer";
3
7 data: object;
8};
9export async function callGoogleSheetsAPI(
10 { serviceAccount, sheetId, action, data }: Args,
11) {
14 );
15 const googleAuthOptions = {
16 scope: ["https://www.googleapis.com/auth/spreadsheets"],
17 };
18 const { access_token } = await getToken(serviceAccount, googleAuthOptions);
19 const result = fetchJSON(
20 `https://sheets.googleapis.com/v4/spreadsheets/${sheetId}/${action}`,
21 {
22 method: "POST",
1import { spotifyMe } from "https://esm.town/v/stevekrouse/spotifyMe";
2import { spotifyAPI } from "https://esm.town/v/stevekrouse/spotifyAPI";
3
4export let spotifyCreatePlaylist = async ({token, ...params}) => spotifyAPI({
5 token,
6 endpoint: `users/${(await spotifyMe(token)).id}/playlists`,
1export const googleClient = async () => {
2 const { google } = await import("npm:googleapis");
3 const key = { client_id: "test", client_secret: "test" };
4 const client = new google.auth.OAuth2(key.client_id, key.client_secret, [
1import { spotifyAPI } from "https://esm.town/v/stevekrouse/spotifyAPI";
2
3export let spotifySearch = ({...params}) => spotifyAPI({
4 endpoint: 'search',
5 ...params
5export const getMuniStopInfo = (stopCode) => {
6 return fetchJSON(
7 `https://api.511.org/transit/StopMonitoring?api_key=${process.env.transitApiKey}&agency=SF&stopCode=${stopCode}`,
8 );
9};
1import { HNcache } from "https://esm.town/v/akkartik/HNcache";
2
3// traverse parent links up to story, but don't make any API requests
4export let hnStoryPure = async (post) => {
5 while (post.parent) {