1import { hiddenAPIInternal } from "https://esm.town/v/stevekrouse/hiddenAPIInternal";
2
3export let hiddenAPI = (...args) => hiddenAPIInternal(...args);
6 const nytimes =
7 await (await fetch(
8 `https://api.nytimes.com/svc/topstories/v2/home.json?api-key=${process.env.nytimes_api_key}`,
9 )).json();
10 const now = Date.now();
1export const testVTClient = (async () => {
2 const { createApiClient } = await import(
3 "https://esm.sh/gh/nbbaier/valtown-zodios@main/src/spec/valtown-client.ts"
4 );
5 const apiClient = createApiClient("https://api.val.town");
6 const params = {
7 params: { username: "stevekrouse", val_name: "fetchJSON" },
8 };
9 const user = await apiClient.getValname(params);
10 return user;
11})();
4export async function testMutateSemantics({
5 stateName,
6 api,
7 mutateExpected,
8 expected,
11}: {
12 stateName: string;
13 api: string;
14 mutateExpected?: boolean;
15 expected?: (old, next) => boolean;
18}) {
19 const { data: last } = await fetchJSON(
20 `${api}/eval/${stateName}`
21 );
22 const now = Date.now();
23 await fetchJSON(
24 `${api}/eval/${mutator(now)}`,
25 authenticated
26 ? {
30 );
31 const { data: next } = await fetchJSON(
32 `${api}/eval/${stateName}`
33 );
34 const mutated = next === now;
4 filter?: any;
5}) => {
6 const { Client, collectPaginatedAPI } = await import(
7 "https://deno.land/x/notion_sdk/src/mod.ts"
8 );
9 const notion = new Client({ auth });
10 return collectPaginatedAPI(notion.databases.query, {
11 database_id: databaseId,
12 filter,
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2import { openaiOpenAPI } from "https://esm.town/v/stevekrouse/openaiOpenAPI";
3
4// https://stevekrouse-chatgptplugin.express.val.run/.well-known/ai-plugin.json
13Vals are JavaScript & TypeScript code.
14They run server-side on Deno.
15\`fetch\` is in the environment to access any PUBLIC real-time APIs or data feeds.
16Answer any questions about times after your cut off date by querying PUBLIC APIs.
17Do NOT use any API that requires a secret key.
18Only use PUBLIC APIs.
19Do NOT use \`YOUR_API_KEY\`.
20Do NOT import axios or node-fetch. Instead use \`fetch\`.
21Do NOT use newlines. Just use semicolons.
25 "type": "none",
26 },
27 "api": {
28 "type": "openapi",
29 "url": "/openapi",
30 },
31 "logo_url":
35 });
36 }
37 else if (req.path === "/openapi") {
38 // OpenAPI Spec
39 // only POST /v1/eval for now
40 res.send(openaiOpenAPI);
41 }
42 else if (req.path === "/v1/eval") {
43 // Proxy /v1/eval to api.val.town
44 try {
45 console.log(req.body);
46 let result = await fetchJSON(
47 "https://api.val.town/v1/eval",
48 { method: "POST", body: JSON.stringify(req.body) },
49 );
1import { exportedKeys } from "https://esm.town/v/stevekrouse/exportedKeys";
2import { thisEmail } from "https://esm.town/v/stevekrouse/thisEmail";
3import { runValAPIAuth } from "https://esm.town/v/stevekrouse/runValAPIAuth";
4
5export const emailEx = runValAPIAuth({
6 val: "@stevekrouse.email",
7 args: [{
8 subject: "test via api",
9 from: { email: thisEmail() },
10 to: [{ email: "steve@val.town" }],
7}) {
8 return fetchJSON(
9 "https://api.openai.com/v1/fine_tuning/jobs",
10 {
11 method: "POST",
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export function resend({ from, to, subject, html, text, apiKey }: {
4 from: string;
5 to: string;
7 html?: string;
8 text?: string;
9 apiKey: string;
10}) {
11 return fetchJSON("https://api.resend.com/emails", {
12 method: "POST",
13 headers: {
14 "Authorization": `Bearer ${apiKey}`,
15 "Content-Type": "application/json",
16 },
1let { valTownInspoList } = await import("https://esm.town/v/rodrigotello/valTownInspoList?v=99");
2import { isValTownTeam } from "https://esm.town/v/stevekrouse/isValTownTeam";
3import { verifyAPIAuth } from "https://esm.town/v/stevekrouse/verifyAPIAuth";
4
5export async function updateInspoList(newList, auth) {
6 let handle = await verifyAPIAuth(auth);
7 if (isValTownTeam(handle)) {
8 valTownInspoList = newList;