1export function runValAPI(name, ...args) {
2 return fetch(`https://api.val.town/v1/run/${name.replace("@", "")}`, {
3 method: "POST",
4 body: JSON.stringify({
7// Make an authenticated request to another user's val
8// Example usage: https://www.val.town/v/stevekrouse.authRequestEx
9export const runValAPIAuth = async ({ val, args, handle, privateKey, keys }: {
10 val: string;
11 args: any;
1import { runValAPIAuth } from "https://esm.town/v/stevekrouse/runValAPIAuth";
2
3// grab the types off turso's client without importing it
6
7export function turso(keys, handle?) {
8 let val = "@std.tursoAPI";
9 let f = (method) => (...args) =>
10 runValAPIAuth({
11 val,
12 args: [method, args],
2import { OpenAI } from "npm:openai";
3
4const openai = new OpenAI({ apiKey: process.env.openai });
5let chatCompletion = await openai.chat.completions.create({
6 messages: [{ role: "user", content: "Make a short joke or pun" }],
4const model = new ChatOpenAI({
5 temperature: 0.9,
6 openAIApiKey: process.env.openai,
7});
8
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
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